test/time_measure_test.cc
author Alpar Juttner <alpar@cs.elte.hu>
Wed, 25 Aug 2010 21:34:58 +0200
changeset 742 16d466589b54
parent 440 88ed40ad0d4f
child 792 761fe0846f49
permissions -rw-r--r--
Backport the CMAKE related changesets from the main branch

[e20fecd1945f] Add check target for CMake (#388)
[e74b5db4f2c6] Put the output of chg-len.py in the version string (#389)
[7d166b8b8018] Safer call of ./scripts/chg-len.py on Windows (#389)
[659ba4805a48] Make CMAKE config more consistent with configure.ac (#390)
[63e4468c680e] Add 'Maintainer' CMAKE build type (#388, #390)
[a725503acfe9] Allow CPACK configuration on all platforms
[10242c611190] Create and install lemon.pc (#393)
[48e29534cf03] The deafult target doesn't build lp_test and mip_test (#388)
[0fbbdd578c06] Full path for DoxygenLayout.xml in Doxyfile.in (#395)
[481496e6d71f] SOURCE_BROWSER Doxygen switch is configurable from CMAKE (#395)
[09282720100b] update-external-tags CMAKE target (#395)
alpar@209
     1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
alpar@119
     2
 *
alpar@209
     3
 * This file is a part of LEMON, a generic C++ optimization library.
alpar@119
     4
 *
alpar@440
     5
 * Copyright (C) 2003-2009
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
using namespace lemon;
alpar@119
    22
alpar@209
    23
void f()
alpar@119
    24
{
alpar@119
    25
  double d=0;
alpar@119
    26
  for(int i=0;i<1000;i++)
alpar@119
    27
    d+=0.1;
alpar@119
    28
}
alpar@119
    29
alpar@209
    30
void g()
alpar@119
    31
{
alpar@119
    32
  static Timer T;
alpar@209
    33
alpar@119
    34
  for(int i=0;i<1000;i++)
alpar@119
    35
    TimeStamp x(T);
alpar@119
    36
}
alpar@119
    37
alpar@119
    38
int main()
alpar@119
    39
{
alpar@119
    40
  Timer T;
alpar@119
    41
  unsigned int n;
kpeter@549
    42
  for(n=0;T.realTime()<0.1;n++) ;
alpar@119
    43
  std::cout << T << " (" << n << " time queries)\n";
kpeter@549
    44
alpar@119
    45
  TimeStamp full;
alpar@119
    46
  TimeStamp t;
kpeter@549
    47
  t=runningTimeTest(f,0.1,&n,&full);
alpar@119
    48
  std::cout << t << " (" << n << " tests)\n";
alpar@119
    49
  std::cout << "Total: " << full << "\n";
alpar@209
    50
kpeter@549
    51
  t=runningTimeTest(g,0.1,&n,&full);
alpar@119
    52
  std::cout << t << " (" << n << " tests)\n";
alpar@119
    53
  std::cout << "Total: " << full << "\n";
alpar@209
    54
alpar@119
    55
  return 0;
alpar@119
    56
}