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