int benchmark(int n_sets, struct LFreeSet2D *sets, double *rays, int algorithm) { int rval = 0; log_info("Running benchmark...\n"); double total_initial_time = get_user_time(); stats_printf("cpu_time:\n"); for (int j = 0; j < n_sets; j++) { log_debug("Set %d...\n", j); double set_initial_time = get_user_time(); struct LFreeSet2D *set = &sets[j]; double *pre_m = &PRE_M[j * 4]; double center = CENTER[j]; rval = LFREE_2D_print_set(set); abort_if(rval, "LFREE_2D_print_set failed"); int wrong_answer = 0; rval = benchmark_set(algorithm, j, set, rays, pre_m, center, &wrong_answer); abort_if(rval, "benchmark_set failed"); double set_duration = get_user_time() - set_initial_time; double avg = (set_duration / N_SAMPLES_PER_SET) * 1000; if(wrong_answer) avg = 1000000; stats_printf(" %d: %.8lf\n", j, avg); log_info(" %3d: %12.3lf ms\n", j, avg); } double total_duration = get_user_time() - total_initial_time; log_info(" %.3lf ms per set \n", total_duration / (n_sets * N_SAMPLES_PER_SET) * 1000); if(algorithm == ALGORITHM_MIP) { log_info(" %.3lf s spent on LP_create\n", MIP_TIME_CREATE); log_info(" %.3lf s spent on LP_optimize\n", MIP_TIME_OPTIMIZE); } CLEANUP: return rval; }
void benchmark(redis::client & c, int TEST_SIZE) { c.flushdb(); benchmark_set (c, TEST_SIZE); c.flushdb(); benchmark_mset(c, TEST_SIZE); benchmark_get (c, TEST_SIZE); benchmark_mget(c, TEST_SIZE); benchmark_incr(c, TEST_SIZE); /// /// Large values /// string val; for(int i=0; i < 256; i++) { val += (char) i; } do { cout << endl; cout << "====== Value size: " << val.size() << " ======" << endl; cout << endl; TEST_SIZE = TEST_SIZE/1.35; c.flushdb(); benchmark_set (c, TEST_SIZE, val); c.flushdb(); benchmark_mset(c, TEST_SIZE, val); benchmark_get (c, TEST_SIZE); benchmark_mget(c, TEST_SIZE); val.append(val); } while( val.size() <= (1024*1024)*2 ); }