Scaffolding  0.1
This program can assemble genome scaffolds using the pairing information in paired-end reads.
profiling.hpp
Go to the documentation of this file.
1 
2 
7 #ifndef PROFILING_HPP
8 #define PROFILING_HPP
9 
10 #include <unistd.h>
11 #include <sys/times.h>
12 #include <time.h>
13 
15 double get_cycles(){
16  return clock();
17 // struct tms tms;
18 // if ( times( &tms ) != (clock_t)-1 )
19 // return (double)tms.tms_utime;
20 }
21 
23 struct timer{
24  double start_time;
25  double stop_time;
26 
28  timer(): start_time(0), stop_time(0) {}
29 
31  void start(){
32  start_time = get_cycles();
33  }
34 
36  void stop(){
37  stop_time = get_cycles();
38  }
39 
41  void pause(){
42  stop_time = get_cycles();
43  }
44 
46  void resume(){
47  start_time += get_cycles() - stop_time;
48  }
49 
51 
52  double cycles_passed() const {
53  return stop_time - start_time;
54  }
55 
57  double seconds_passed() const {
58 // return cycles_passed() / (double)sysconf( _SC_CLK_TCK );
59  return cycles_passed() / CLOCKS_PER_SEC;
60  }
61 };
62 
63 #endif
64 
double start_time
last time the timer was started
Definition: profiling.hpp:24
double stop_time
last time the timer was stopped
Definition: profiling.hpp:25
double get_cycles()
get the number of cycles this program has gone through
Definition: profiling.hpp:15
double seconds_passed() const
return the number of seconds passed between last start and last stop (see cycles_passed()) ...
Definition: profiling.hpp:57
void pause()
pause the timer (= stop())
Definition: profiling.hpp:41
a simple timer class that can be paused and resumed
Definition: profiling.hpp:23
void resume()
resume the timer by setting an artificial start_time
Definition: profiling.hpp:46
void stop()
stop the timer
Definition: profiling.hpp:36
void start()
start the timer
Definition: profiling.hpp:31
double cycles_passed() const
return the number of cycles passed between last start and last stop
Definition: profiling.hpp:52
timer()
constructor
Definition: profiling.hpp:28