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@1956
|
5 |
* Copyright (C) 2003-2006
|
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 |
double d=0;
|
alpar@1960
|
40 |
for(int i=0;i<1000;i++)
|
alpar@1960
|
41 |
TimeStamp x(T);
|
alpar@1960
|
42 |
}
|
alpar@1960
|
43 |
|
alpar@545
|
44 |
int main()
|
alpar@545
|
45 |
{
|
alpar@545
|
46 |
Timer T;
|
alpar@1689
|
47 |
int n;
|
alpar@1689
|
48 |
for(n=0;T.realTime()<1.0;n++) ;
|
alpar@1689
|
49 |
std::cout << T << " (" << n << " time queries)\n";
|
alpar@1847
|
50 |
T.restart();
|
alpar@1689
|
51 |
while(T.realTime()<2.0) ;
|
alpar@545
|
52 |
std::cout << T << '\n';
|
alpar@1689
|
53 |
TimeStamp full;
|
alpar@1960
|
54 |
TimeStamp t;
|
alpar@1960
|
55 |
t=runningTimeTest(f,1,&n,&full);
|
alpar@1960
|
56 |
std::cout << t << " (" << n << " tests)\n";
|
alpar@1960
|
57 |
std::cout << "Total: " << full << "\n";
|
alpar@1960
|
58 |
|
alpar@1960
|
59 |
t=runningTimeTest(g,1,&n,&full);
|
alpar@1689
|
60 |
std::cout << t << " (" << n << " tests)\n";
|
alpar@1689
|
61 |
std::cout << "Total: " << full << "\n";
|
alpar@567
|
62 |
|
alpar@566
|
63 |
return 0;
|
alpar@545
|
64 |
}
|