~sysbench-developers/sysbench/0.4

« back to all changes in this revision

Viewing changes to sysbench/sb_timer.c

  • Committer: Alexey Kopytov
  • Date: 2011-07-21 13:29:08 UTC
  • Revision ID: akopytov@gmail.com-20110721132908-tt2u2572kihrnzs6
Bug #811105: Add an option to dump full stats after specified time
             intervals.

Added a new --report-checkpoints option that allows to dump full
statistics and reset all counters at specified points in time. The
argument is a list of comma-separated values representing the amount of
time in seconds elapsed from start of test when report checkpoint(s)
must be performed. Report checkpoints are off by   Report checkpoints
are off by default.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
static inline void sb_timer_update(sb_timer_t *t)
36
36
{
37
 
  struct timespec time_end;
38
 
 
39
 
  SB_GETTIME(&time_end);
40
 
  t->elapsed = TIMESPEC_DIFF(time_end, t->time_start);
 
37
  SB_GETTIME(&t->time_end);
 
38
  t->elapsed = TIMESPEC_DIFF(t->time_end, t->time_start);
41
39
}
42
40
 
43
41
/* initialize timer */
45
43
 
46
44
void sb_timer_init(sb_timer_t *t)
47
45
{
 
46
  memset(&t->time_start, 0, sizeof(struct timespec));
 
47
  memset(&t->time_end, 0, sizeof(struct timespec));
 
48
  memset(&t->time_split, 0, sizeof(struct timespec));
 
49
  sb_timer_reset(t);
 
50
  t->state = TIMER_INITIALIZED;
 
51
}
 
52
 
 
53
 
 
54
/* Reset timer counters, but leave the current state intact */
 
55
void sb_timer_reset(sb_timer_t *t)
 
56
{
48
57
  t->min_time = 0xffffffffffffffffULL;
49
58
  t->max_time = 0;
50
59
  t->sum_time = 0;
51
60
  t->events = 0;
52
 
  t->state = TIMER_INITIALIZED;
53
 
}
54
 
 
 
61
  t->elapsed = 0;
 
62
}
 
63
 
 
64
 
 
65
/* check whether the timer is initialized */
 
66
int sb_timer_initialized(sb_timer_t *t)
 
67
{
 
68
  return t->state != TIMER_UNINITIALIZED;
 
69
}
55
70
 
56
71
/* start timer */
57
72
 
148
163
      log_text(LOG_WARNING, "timer was never started");
149
164
      return 0;
150
165
    case TIMER_STOPPED:
151
 
      log_text(LOG_WARNING, "timer was already stopped");
152
 
      return 0;;
 
166
      res = TIMESPEC_DIFF(t->time_end, t->time_split);
 
167
      t->time_split = t->time_end;
 
168
      if (res)
 
169
        return res;
 
170
      else
 
171
      {
 
172
        log_text(LOG_WARNING, "timer was already stopped");
 
173
        return 0;
 
174
      }
153
175
    case TIMER_RUNNING:
154
176
      break;
155
177
    default: