static int ms_check_para(void);
static void ms_statistic_init(void);
static void ms_stats_init(void);
-static void ms_print_statistics(int time);
+static void ms_print_statistics(int in_time);
static void ms_print_memslap_stats(struct timeval *start_time,
struct timeval *end_time);
static void ms_monitor_slap_mode(void);
break;
case OPT_THREAD_NUMBER: /* --threads or -T */
- ms_setting.nthreads= (int)strtol(optarg, (char **) NULL, 10);
+ ms_setting.nthreads= (uint32_t)strtoul(optarg, (char **) NULL, 10);
if (ms_setting.nthreads <= 0)
{
fprintf(stderr, "Threads number must be greater than 0.:-)\n");
break;
case OPT_SOCK_PER_CONN: /* --conn_sock or -n */
- ms_setting.sock_per_conn= (int)strtol(optarg, (char **) NULL, 10);
+ ms_setting.sock_per_conn= (uint32_t)strtoul(optarg, (char **) NULL, 10);
if (ms_setting.sock_per_conn <= 0)
{
fprintf(stderr, "Number of socks of each concurrency "
break;
case OPT_REP_WRITE_SRV: /* --rep_write or -p */
- ms_setting.rep_write_srv= (int)strtol(optarg, (char **) NULL, 10);
+ ms_setting.rep_write_srv= (uint32_t)strtoul(optarg, (char **) NULL, 10);
if (ms_setting.rep_write_srv <= 0)
{
fprintf(stderr,
char buf[1024];
char *pos= buf;
- pos+= sprintf(pos, "cmd_get: %zu\n",
- ms_stats.cmd_get);
- pos+= sprintf(pos, "cmd_set: %zu\n",
- ms_stats.cmd_set);
- pos+= sprintf(pos, "get_misses: %zu\n",
- ms_stats.get_misses);
+ pos+= snprintf(pos,
+ sizeof(buf), "cmd_get: %lu\n",
+ (unsigned long) ms_stats.cmd_get);
+ pos+= snprintf(pos,
+ sizeof(buf) - (size_t)(pos -buf),
+ "cmd_set: %lu\n",
+ (unsigned long) ms_stats.cmd_set);
+ pos+= snprintf(pos,
+ sizeof(buf) - (size_t)(pos -buf),
+ "get_misses: %lu\n",
+ (unsigned long) ms_stats.get_misses);
if (ms_setting.verify_percent > 0)
{
- pos+= sprintf(pos, "verify_misses: %zu\n",
- ms_stats.vef_miss);
- pos+= sprintf(pos, "verify_failed: %zu\n",
- ms_stats.vef_failed);
+ pos+= snprintf(pos,
+ sizeof(buf) - (size_t)(pos -buf),
+ "verify_misses: %lu\n",
+ (unsigned long) ms_stats.vef_miss);
+ pos+= snprintf(pos,
+ sizeof(buf) - (size_t)(pos -buf),
+ "verify_failed: %lu\n",
+ (unsigned long) ms_stats.vef_failed);
}
if (ms_setting.exp_ver_per > 0)
{
- pos+= sprintf(pos, "expired_get: %zu\n",
- ms_stats.exp_get);
- pos+= sprintf(pos, "unexpired_unget: %zu\n",
- ms_stats.unexp_unget);
+ pos+= snprintf(pos,
+ sizeof(buf) - (size_t)(pos -buf),
+ "expired_get: %lu\n",
+ (unsigned long) ms_stats.exp_get);
+ pos+= snprintf(pos,
+ sizeof(buf) - (size_t)(pos -buf),
+ "unexpired_unget: %lu\n",
+ (unsigned long) ms_stats.unexp_unget);
}
- pos+= sprintf(pos,
- "written_bytes: %zu\n",
- ms_stats.bytes_written);
- pos+= sprintf(pos, "read_bytes: %zu\n",
- ms_stats.bytes_read);
- pos+= sprintf(pos, "object_bytes: %zu\n",
- ms_stats.obj_bytes);
+ pos+= snprintf(pos,
+ sizeof(buf) - (size_t)(pos -buf),
+ "written_bytes: %lu\n",
+ (unsigned long) ms_stats.bytes_written);
+ pos+= snprintf(pos,
+ sizeof(buf) - (size_t)(pos -buf),
+ "read_bytes: %lu\n",
+ (unsigned long) ms_stats.bytes_read);
+ pos+= snprintf(pos,
+ sizeof(buf) - (size_t)(pos -buf),
+ "object_bytes: %lu\n",
+ (unsigned long) ms_stats.obj_bytes);
if (ms_setting.udp || ms_setting.facebook_test)
{
- pos+= sprintf(pos, "packet_disorder: %zu\n",
- ms_stats.pkt_disorder);
- pos+= sprintf(pos, "packet_drop: %zu\n",
- ms_stats.pkt_drop);
- pos+= sprintf(pos, "udp_timeout: %zu\n",
- ms_stats.udp_timeout);
+ pos+= snprintf(pos,
+ sizeof(buf) - (size_t)(pos -buf),
+ "packet_disorder: %lu\n",
+ (unsigned long) ms_stats.pkt_disorder);
+ pos+= snprintf(pos,
+ sizeof(buf) - (size_t)(pos -buf),
+ "packet_drop: %lu\n",
+ (unsigned long)ms_stats.pkt_drop);
+ pos+= snprintf(pos,
+ sizeof(buf) - (size_t)(pos -buf),
+ "udp_timeout: %lu\n",
+ (unsigned long)ms_stats.udp_timeout);
}
if (ms_setting.stat_freq > 0)
}
int64_t time_diff= ms_time_diff(start_time, end_time);
- pos+= sprintf(
- pos,
- "\nRun time: %.1fs Ops: %llu TPS: %.0Lf Net_rate: %.1fM/s\n",
- (double)time_diff / 1000000,
- (unsigned long long)(ms_stats.cmd_get + ms_stats.cmd_set),
- (ms_stats.cmd_get
- + ms_stats.cmd_set) / ((long double)time_diff / 1000000),
- (double)(
- ms_stats.bytes_written
- + ms_stats.bytes_read) / 1024 / 1024
- / ((double)time_diff / 1000000));
+ pos+= snprintf(pos,
+ sizeof(buf) - (size_t)(pos -buf),
+ "\nRun time: %.1fs Ops: %llu TPS: %.0Lf Net_rate: %.1fM/s\n",
+ (double)time_diff / 1000000,
+ (unsigned long long)(ms_stats.cmd_get + ms_stats.cmd_set),
+ (ms_stats.cmd_get
+ + ms_stats.cmd_set) / ((long double)time_diff / 1000000),
+ (double)(
+ ms_stats.bytes_written
+ + ms_stats.bytes_read) / 1024 / 1024
+ / ((double)time_diff / 1000000));
+ assert(pos <= buf);
fprintf(stdout, "%s", buf);
fflush(stdout);
{
/* Wait all the connects complete warm up. */
pthread_mutex_lock(&ms_global.warmup_lock.lock);
- while (ms_global.warmup_lock.count < (int)ms_setting.nconns) {
+ while (ms_global.warmup_lock.count < ms_setting.nconns)
+ {
pthread_cond_wait(&ms_global.warmup_lock.cond, &ms_global.warmup_lock.lock);
}
pthread_mutex_unlock(&ms_global.warmup_lock.lock);
* We loop until we know that all connects have cleaned up.
*/
pthread_mutex_lock(&ms_global.run_lock.lock);
- while (ms_global.run_lock.count < (int)ms_setting.nconns)
+ while (ms_global.run_lock.count < ms_setting.nconns)
{
pthread_cond_wait(&ms_global.run_lock.cond, &ms_global.run_lock.lock);
}