| [209] | 1 | /* -*- mode: C++; indent-tabs-mode: nil; -*- | 
|---|
| [119] | 2 | * | 
|---|
| [209] | 3 | * This file is a part of LEMON, a generic C++ optimization library. | 
|---|
| [119] | 4 | * | 
|---|
| [1092] | 5 | * Copyright (C) 2003-2013 | 
|---|
| [119] | 6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport | 
|---|
|  | 7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). | 
|---|
|  | 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 |  | 
|---|
|  | 19 | #include <lemon/time_measure.h> | 
|---|
| [997] | 20 | #include <lemon/concept_check.h> | 
|---|
| [119] | 21 |  | 
|---|
|  | 22 | using namespace lemon; | 
|---|
|  | 23 |  | 
|---|
| [209] | 24 | void f() | 
|---|
| [119] | 25 | { | 
|---|
|  | 26 | double d=0; | 
|---|
|  | 27 | for(int i=0;i<1000;i++) | 
|---|
|  | 28 | d+=0.1; | 
|---|
|  | 29 | } | 
|---|
|  | 30 |  | 
|---|
| [209] | 31 | void g() | 
|---|
| [119] | 32 | { | 
|---|
|  | 33 | static Timer T; | 
|---|
| [209] | 34 |  | 
|---|
| [119] | 35 | for(int i=0;i<1000;i++) | 
|---|
| [997] | 36 | { | 
|---|
|  | 37 | TimeStamp x(T); | 
|---|
| [1083] | 38 | ::lemon::ignore_unused_variable_warning(x); | 
|---|
| [997] | 39 | } | 
|---|
| [119] | 40 | } | 
|---|
|  | 41 |  | 
|---|
|  | 42 | int main() | 
|---|
|  | 43 | { | 
|---|
|  | 44 | Timer T; | 
|---|
|  | 45 | unsigned int n; | 
|---|
| [558] | 46 | for(n=0;T.realTime()<0.1;n++) ; | 
|---|
| [119] | 47 | std::cout << T << " (" << n << " time queries)\n"; | 
|---|
| [558] | 48 |  | 
|---|
| [119] | 49 | TimeStamp full; | 
|---|
|  | 50 | TimeStamp t; | 
|---|
| [558] | 51 | t=runningTimeTest(f,0.1,&n,&full); | 
|---|
| [119] | 52 | std::cout << t << " (" << n << " tests)\n"; | 
|---|
|  | 53 | std::cout << "Total: " << full << "\n"; | 
|---|
| [209] | 54 |  | 
|---|
| [558] | 55 | t=runningTimeTest(g,0.1,&n,&full); | 
|---|
| [119] | 56 | std::cout << t << " (" << n << " tests)\n"; | 
|---|
|  | 57 | std::cout << "Total: " << full << "\n"; | 
|---|
| [209] | 58 |  | 
|---|
| [119] | 59 | return 0; | 
|---|
|  | 60 | } | 
|---|