-
Notifications
You must be signed in to change notification settings - Fork 0
/
t-timer-c11.cc
51 lines (40 loc) · 1.36 KB
/
t-timer-c11.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
using namespace std;
//using namespace lvv;
#include <stdint.h>
#include <lvv/timer.h>
#include <chrono>
#include <unistd.h>
//using lvv::timer_t;
int main() {
cout << lvv::read_tick() << " -- 1 \n";
cout << lvv::read_tick() << " -- 1 \n";
cout << lvv::read_tick() << " -- 1 \n";
cout << lvv::read_tick() << " -- 1 \n";
cout << lvv::read_tick() << " -- 1 \n";
cout << lvv::read_tick() << " -- 1 \n";
cout << lvv::read_tick() << " -- 1 \n";
cout << lvv::read_tick() << " -- 1 \n";
cout << lvv::read_tick() << " -- 1 \n";
cout << "timer_t CTOR\n";
lvv::timer_t verboze_t(true);
lvv::timer_t t;
auto start_t = std::chrono::system_clock::now();
t.print("timer.print() MSG test");
cout << "timer()=" << t() << endl;
cout << "\n*** usleep 1000\n";
usleep(useconds_t(10000));
cout << "interval_ticks(): " << t.interval_ticks() << '\n';
t.print("2nd print()");
cout << "\n*** usleep 2000\n";
usleep(useconds_t(20000));
t.print("3rd print()");
cout << "stream << test " << t << endl;
cout << "\n*** usleep 3000\n";
usleep(useconds_t(30000));
auto end_t = std::chrono::system_clock::now();
auto dur_t = end_t - start_t;
auto dur_ms = std::chrono::duration_cast <std::chrono::milliseconds>(dur_t);
cout << "\nchrono timer: " << dur_ms.count() << " ms\n";
cout << "Last line will be from timer_t destructor \n";
}