void run_benchmarks(int argc, char** argv) { benchmark_t* benchmark = global_benchmarks; while (benchmark && benchmark->name != NULL) { bm_start(benchmark->name); bm_end(benchmark->name); ++benchmark; } }
int32_t main(int32_t argc, char *argv[]) { const char *options = "vh"; int32_t opt; int32_t i, j; int32_t size; int32_t verbose = 0; while ((opt = getopt(argc, argv, options)) != -1) { switch (opt) { case 'v': verbose++; break; case 'h': default: show_usage(argv[0]); exit(0); break; } } signal(SIGINT, sigterm_handler); qb_log_init("rbwriter", LOG_USER, LOG_EMERG); qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_ENABLED, QB_FALSE); qb_log_filter_ctl(QB_LOG_STDERR, QB_LOG_FILTER_ADD, QB_LOG_FILTER_FILE, "*", LOG_INFO + verbose); qb_log_ctl(QB_LOG_STDERR, QB_LOG_CONF_ENABLED, QB_TRUE); bmc_connect(); for (j = 1; j < 49; j++) { bm_start(); size = 7 * (j + 1) * j; if (size > BUFFER_CHUNK_SIZE) { size = BUFFER_CHUNK_SIZE; } for (i = 0; i < ITERATIONS; i++) { bmc_send_nozc(size); } bm_finish("ringbuffer", size); } qb_rb_close(rb); return EXIT_SUCCESS; }
static void *benchmark(void *ctx) { struct bm_ctx *bm_ctx = (struct bm_ctx *)ctx; int32_t res; bmc_connect(bm_ctx); bm_start(bm_ctx); for (;;) { bm_ctx->counter++; res = bmc_send_nozc(bm_ctx, 1000 * bm_ctx->multi); if (alarm_notice || res == -1) { bm_finish(bm_ctx, "send_nozc", 1000 * bm_ctx->multi); bmc_disconnect(bm_ctx); return (NULL); } } }