~sysbench-developers/sysbench/0.4

« back to all changes in this revision

Viewing changes to sysbench/sb_options.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:
29
29
# include <ctype.h>
30
30
#endif
31
31
 
 
32
#ifdef HAVE_LIMITS_H
 
33
# include <limits.h>
 
34
#endif
 
35
 
32
36
#include "sb_options.h"
33
37
 
34
38
#define VALUE_DELIMITER '='
177
181
  option_t       *opt;
178
182
  value_t        *val;
179
183
  sb_list_item_t *pos;
 
184
  long           res;
 
185
  char           *endptr;
180
186
 
181
187
  opt = find_option(&options, name);
182
188
  if (opt == NULL)
185
191
  SB_LIST_FOR_EACH(pos, &opt->values)
186
192
  {
187
193
    val = SB_LIST_ENTRY(pos, value_t, listitem);
188
 
    return atoi(val->data);
 
194
    res = strtol(val->data, &endptr, 10);
 
195
    if (*endptr != '\0' || res > INT_MAX || res < INT_MIN)
 
196
    {
 
197
      fprintf(stderr, "Invalid value for the '%s' option: '%s'\n",
 
198
              name, val->data);
 
199
      exit(EXIT_FAILURE);
 
200
    }
 
201
    return (int) res;
189
202
  }
190
203
 
191
204
  return 0;
606
619
    
607
620
  return 0;
608
621
}
609