CEBL  2.1
Timer.hpp
Go to the documentation of this file.
1 /*
2 * CEBL : CSU EEG Brain-Computer Interface Lab
3 *
4 * Author: Jeshua Bratman - jeshuabratman@gmail.com
5 *
6 * This file is part of CEBL.
7 *
8 * CEBL is free software; you can redistribute it and/or modify it.
9 * We only ask that if you use our code that you cite the source in
10 * your project or publication.
11 *
12 * EEG Group (www.cs.colostate.edu/eeg)
13 * Department of Computer Science
14 * Colorado State University
15 *
16 */
17 
25 #ifndef TIMER_H
26 #define TIMER_H
27 
28 #include <stdio.h>
29 #include <sys/timeb.h>
30 
31 class Timer
32 {
33 private:
34  timeb start_time;
35 public:
37  {
38  restart();
39  }
40 
41  //restart timer to 0
42  void restart()
43  {
44  ftime(&start_time);
45  }
46  //time elapsed in milliseconds
47  long elapsed()
48  {
49  timeb current_time;
50  long diff;
51  ftime(&current_time);
52  diff = (long) (1000.0 * (current_time.time - start_time.time)
53  + (current_time.millitm - start_time.millitm));
54  return diff;
55  }
56 
57 
58 };
59 
60 #endif