alpar@906
|
1 |
/* -*- C++ -*-
|
alpar@906
|
2 |
*
|
alpar@1956
|
3 |
* This file is a part of LEMON, a generic C++ optimization library
|
alpar@1956
|
4 |
*
|
alpar@2391
|
5 |
* Copyright (C) 2003-2007
|
alpar@1956
|
6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
alpar@1359
|
7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES).
|
alpar@906
|
8 |
*
|
alpar@906
|
9 |
* Permission to use, modify and distribute this software is granted
|
alpar@906
|
10 |
* provided that this copyright notice appears in all copies. For
|
alpar@906
|
11 |
* precise terms see the accompanying LICENSE file.
|
alpar@906
|
12 |
*
|
alpar@906
|
13 |
* This software is provided "AS IS" with no warranty of any kind,
|
alpar@906
|
14 |
* express or implied, and with no claim as to its suitability for any
|
alpar@906
|
15 |
* purpose.
|
alpar@906
|
16 |
*
|
alpar@906
|
17 |
*/
|
alpar@906
|
18 |
|
alpar@921
|
19 |
#include <lemon/time_measure.h>
|
alpar@545
|
20 |
|
alpar@545
|
21 |
///\file \brief Test cases for time_measure.h
|
alpar@545
|
22 |
///
|
alpar@545
|
23 |
///\todo To be extended
|
alpar@545
|
24 |
|
alpar@545
|
25 |
|
alpar@921
|
26 |
using namespace lemon;
|
alpar@545
|
27 |
|
alpar@1689
|
28 |
void f()
|
alpar@1689
|
29 |
{
|
alpar@1689
|
30 |
double d=0;
|
alpar@1960
|
31 |
for(int i=0;i<1000;i++)
|
alpar@1689
|
32 |
d+=0.1;
|
alpar@1689
|
33 |
}
|
alpar@1689
|
34 |
|
alpar@1960
|
35 |
void g()
|
alpar@1960
|
36 |
{
|
alpar@1960
|
37 |
static Timer T;
|
alpar@1960
|
38 |
|
alpar@1960
|
39 |
for(int i=0;i<1000;i++)
|
alpar@1960
|
40 |
TimeStamp x(T);
|
alpar@1960
|
41 |
}
|
alpar@1960
|
42 |
|
alpar@545
|
43 |
int main()
|
alpar@545
|
44 |
{
|
alpar@545
|
45 |
Timer T;
|
alpar@2243
|
46 |
unsigned int n;
|
alpar@1689
|
47 |
for(n=0;T.realTime()<1.0;n++) ;
|
alpar@1689
|
48 |
std::cout << T << " (" << n << " time queries)\n";
|
alpar@1847
|
49 |
T.restart();
|
alpar@1689
|
50 |
while(T.realTime()<2.0) ;
|
alpar@545
|
51 |
std::cout << T << '\n';
|
alpar@1689
|
52 |
TimeStamp full;
|
alpar@1960
|
53 |
TimeStamp t;
|
alpar@1960
|
54 |
t=runningTimeTest(f,1,&n,&full);
|
alpar@1960
|
55 |
std::cout << t << " (" << n << " tests)\n";
|
alpar@1960
|
56 |
std::cout << "Total: " << full << "\n";
|
alpar@1960
|
57 |
|
alpar@1960
|
58 |
t=runningTimeTest(g,1,&n,&full);
|
alpar@1689
|
59 |
std::cout << t << " (" << n << " tests)\n";
|
alpar@1689
|
60 |
std::cout << "Total: " << full << "\n";
|
alpar@567
|
61 |
|
alpar@566
|
62 |
return 0;
|
alpar@545
|
63 |
}
|