test/time_measure_test.cc
author Alpar Juttner <alpar@cs.elte.hu>
Sat, 17 May 2008 06:30:02 +0100
changeset 156 e561aa7675de
child 171 02f4d5d9bfd7
permissions -rw-r--r--
More flexible header names in .lgf + largely improved doc
alpar@119
     1
/* -*- C++ -*-
alpar@119
     2
 *
alpar@119
     3
 * This file is a part of LEMON, a generic C++ optimization library
alpar@119
     4
 *
alpar@119
     5
 * Copyright (C) 2003-2008
alpar@119
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@119
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@119
     8
 *
alpar@119
     9
 * Permission to use, modify and distribute this software is granted
alpar@119
    10
 * provided that this copyright notice appears in all copies. For
alpar@119
    11
 * precise terms see the accompanying LICENSE file.
alpar@119
    12
 *
alpar@119
    13
 * This software is provided "AS IS" with no warranty of any kind,
alpar@119
    14
 * express or implied, and with no claim as to its suitability for any
alpar@119
    15
 * purpose.
alpar@119
    16
 *
alpar@119
    17
 */
alpar@119
    18
alpar@119
    19
#include <lemon/time_measure.h>
alpar@119
    20
alpar@119
    21
///\file \brief Test cases for time_measure.h
alpar@119
    22
///
alpar@119
    23
///\todo To be extended
alpar@119
    24
alpar@119
    25
alpar@119
    26
using namespace lemon;
alpar@119
    27
alpar@119
    28
void f() 
alpar@119
    29
{
alpar@119
    30
  double d=0;
alpar@119
    31
  for(int i=0;i<1000;i++)
alpar@119
    32
    d+=0.1;
alpar@119
    33
}
alpar@119
    34
alpar@119
    35
void g() 
alpar@119
    36
{
alpar@119
    37
  static Timer T;
alpar@119
    38
  
alpar@119
    39
  for(int i=0;i<1000;i++)
alpar@119
    40
    TimeStamp x(T);
alpar@119
    41
}
alpar@119
    42
alpar@119
    43
int main()
alpar@119
    44
{
alpar@119
    45
  Timer T;
alpar@119
    46
  unsigned int n;
alpar@119
    47
  for(n=0;T.realTime()<1.0;n++) ;
alpar@119
    48
  std::cout << T << " (" << n << " time queries)\n";
alpar@119
    49
  T.restart();
alpar@119
    50
  while(T.realTime()<2.0) ;
alpar@119
    51
  std::cout << T << '\n';
alpar@119
    52
  TimeStamp full;
alpar@119
    53
  TimeStamp t;
alpar@119
    54
  t=runningTimeTest(f,1,&n,&full);
alpar@119
    55
  std::cout << t << " (" << n << " tests)\n";
alpar@119
    56
  std::cout << "Total: " << full << "\n";
alpar@119
    57
  
alpar@119
    58
  t=runningTimeTest(g,1,&n,&full);
alpar@119
    59
  std::cout << t << " (" << n << " tests)\n";
alpar@119
    60
  std::cout << "Total: " << full << "\n";
alpar@119
    61
  
alpar@119
    62
  return 0;
alpar@119
    63
}