summaryrefslogtreecommitdiff
path: root/src/Clock.cxx
blob: bacf373125f32b581c5fe6e5fe6adbe1c651914d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
namespace PluggIt {

class Clock
{
     private long long base;
     private char      str[20];

     public Clock() {
          Reset();
     }

     public void Reset() {
          base = direct_clock_get_micros();
     }

     public float GetTime() {
          return (direct_clock_get_micros() - base) / 1000000.0f;
     }

     public const char *GetString() {
          float time    = GetTime();
          int   seconds = (int) time;
          int   minutes = seconds / 60;

          snprintf( str, sizeof(str), "%02d:%02d", minutes, seconds );

          return str;
     }
};

}