-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstopwatch_reporter_example.cpp
42 lines (33 loc) · 1.23 KB
/
stopwatch_reporter_example.cpp
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
// example/stopwatch_reporter_example.cpp
// ---------------------------------------------------
// Copyright Beman Dawes
// 2006, 2008 Copyright 2009-2011 Vicente J. Botet Escriba Distributed under
// the Boost Software License, Version 1.0. See
// http://www.boost.org/LICENSE_1_0.txt See
// http://www.boost.org/libs/chrono/stopwatches for documentation.
#include "simple_stopwatch.hpp"
#include <cmath>
using namespace boost::chrono;
void f1(long j)
{
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
stopwatch_reporter<strict_stopwatch<> > sw;
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
for (long i = 0; i < j; ++i) {
std::sqrt(123.456L); // burn some time
}
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
}
int main()
{
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
stopwatch_reporter<strict_stopwatch<> > sw;
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
f1(1000);
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
f1(2000);
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
f1(3000);
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
return 0;
}