| Last change
                  on this file since 1792:febe52db9b67 was
                  1689:f1795dafe42c,
                  checked in by Alpar Juttner, 20 years ago | 
        
          | runningTimeTest(): a tool to measure running times more precisely.
TimeStamp? now uses double to count cpu-times
'get's removed from the query functions of Times and TimeStamp?
 | 
        | File size:
            1.1 KB | 
      
      
        
  | Rev | Line |  | 
|---|
| [906] | 1 | /* -*- C++ -*- | 
|---|
| [1435] | 2 | * test/time_measure_test.cc - Part of LEMON, a generic C++ optimization library | 
|---|
| [906] | 3 | * | 
|---|
| [1164] | 4 | * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport | 
|---|
| [1359] | 5 | * (Egervary Research Group on Combinatorial Optimization, EGRES). | 
|---|
| [906] | 6 | * | 
|---|
|  | 7 | * Permission to use, modify and distribute this software is granted | 
|---|
|  | 8 | * provided that this copyright notice appears in all copies. For | 
|---|
|  | 9 | * precise terms see the accompanying LICENSE file. | 
|---|
|  | 10 | * | 
|---|
|  | 11 | * This software is provided "AS IS" with no warranty of any kind, | 
|---|
|  | 12 | * express or implied, and with no claim as to its suitability for any | 
|---|
|  | 13 | * purpose. | 
|---|
|  | 14 | * | 
|---|
|  | 15 | */ | 
|---|
|  | 16 |  | 
|---|
| [921] | 17 | #include <lemon/time_measure.h> | 
|---|
| [545] | 18 |  | 
|---|
|  | 19 | ///\file \brief Test cases for time_measure.h | 
|---|
|  | 20 | /// | 
|---|
|  | 21 | ///\todo To be extended | 
|---|
|  | 22 |  | 
|---|
|  | 23 |  | 
|---|
| [921] | 24 | using namespace lemon; | 
|---|
| [545] | 25 |  | 
|---|
| [1689] | 26 | void f() | 
|---|
|  | 27 | { | 
|---|
|  | 28 | double d=0; | 
|---|
|  | 29 | for(int i=0;i<10000;i++) | 
|---|
|  | 30 | d+=0.1; | 
|---|
|  | 31 | } | 
|---|
|  | 32 |  | 
|---|
| [545] | 33 | int main() | 
|---|
|  | 34 | { | 
|---|
|  | 35 | Timer T; | 
|---|
| [1689] | 36 | int n; | 
|---|
|  | 37 | for(n=0;T.realTime()<1.0;n++) ; | 
|---|
|  | 38 | std::cout << T << " (" << n << " time queries)\n"; | 
|---|
|  | 39 | T.reset(); | 
|---|
|  | 40 | while(T.realTime()<2.0) ; | 
|---|
| [545] | 41 | std::cout << T << '\n'; | 
|---|
| [1689] | 42 | TimeStamp full; | 
|---|
|  | 43 | TimeStamp t=runningTimeTest(f,1,&n,&full); | 
|---|
|  | 44 | std::cout << t << " (" << n << " tests)\n"; | 
|---|
|  | 45 | std::cout << "Total: " << full << "\n"; | 
|---|
| [567] | 46 |  | 
|---|
| [566] | 47 | return 0; | 
|---|
| [545] | 48 | } | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.