COIN-OR::LEMON - Graph Library

source: lemon-main/test/time_measure_test.cc @ 835:b9b2e8abe70b

Last change on this file since 835:b9b2e8abe70b was 558:f53d641aa967, checked in by Peter Kovacs <kpeter@…>, 16 years ago

Improve timer and counter tests (#253)

  • Do not print the output of counter_test.cc.
  • Check the output of counter_test.cc.
  • Shorten the running time of time_measure_test.cc.
File size: 1.2 KB
RevLine 
[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 *
[440]5 * Copyright (C) 2003-2009
[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>
20
21using namespace lemon;
22
[209]23void f()
[119]24{
25  double d=0;
26  for(int i=0;i<1000;i++)
27    d+=0.1;
28}
29
[209]30void g()
[119]31{
32  static Timer T;
[209]33
[119]34  for(int i=0;i<1000;i++)
35    TimeStamp x(T);
36}
37
38int main()
39{
40  Timer T;
41  unsigned int n;
[558]42  for(n=0;T.realTime()<0.1;n++) ;
[119]43  std::cout << T << " (" << n << " time queries)\n";
[558]44
[119]45  TimeStamp full;
46  TimeStamp t;
[558]47  t=runningTimeTest(f,0.1,&n,&full);
[119]48  std::cout << t << " (" << n << " tests)\n";
49  std::cout << "Total: " << full << "\n";
[209]50
[558]51  t=runningTimeTest(g,0.1,&n,&full);
[119]52  std::cout << t << " (" << n << " tests)\n";
53  std::cout << "Total: " << full << "\n";
[209]54
[119]55  return 0;
56}
Note: See TracBrowser for help on using the repository browser.