// =====================================================================
//  $Id: timer.cc,v 1.2 2003/06/27 10:03:14 goiwai Exp $
//  $Name: CLDAQ-1-06-02 $
// =====================================================================
#include "TSystemTimer.hh"
#include "TBenchmark.hh"

Tvoid CPUconsume();

int main( int argc, char** argv, char** envv )
{
  TBenchmark bench;
  bench.Start();
  TSystemTimer timer;
  for ( Tint i = 1; i <= 10; i ++ ) {
    Tcout << i << "00ms sleep with usleep()." << Tendl;
    timer.Start();
    usleep( i * 100 * 1000 );
    CPUconsume();
    timer.Lap();
    Tcout << timer << Tendl;
  }
  timer.Stop();
  bench.Stop();
  Tcout << timer << Tendl;
  Tcout << bench << Tendl;

  return( 0 );
}

Tvoid CPUconsume()
{
  Tdouble z;
  for ( Tint i = 0; i < 0x10000000; i ++ ) {
    z *= (Tdouble)( i * i );
  }
  return;
}
