23 #ifndef _ISOC99_SOURCE 24 #define _ISOC99_SOURCE 49 printf(
"Available benchmarks:\n");
50 for (
set =
last;
set !=
NULL;
set =
set->us_prev)
51 printf(
"%s\n", set->us_name);
58 for (
set =
last;
set !=
NULL;
set =
set->us_prev) {
59 if (strcmp(set->us_name,
name) == 0) {
65 printf(
"No such benchmark: %s\n",
name);
81 while (
t->tv_usec < 0) {
83 t->tv_usec += 1000000;
85 while (
t->tv_usec >= 1000000) {
87 t->tv_usec -= 1000000;
94 diff->tv_sec += end->tv_sec -
start->tv_sec;
96 diff->tv_usec += end->tv_usec -
start->tv_usec;
100 static double delay(
const struct timeval *
start,
const struct timeval *end)
106 return diff.tv_sec + ((double)
diff.tv_usec)/1000000;
112 struct timeval
start;
125 gettimeofday(&end,
NULL);
151 uint64_t bw_kibps = 0;
154 printf(
"\t%12.12s: [%7s] %6s %6s %6s %6s %8s %9s %11s %11s %12s %8s %8s %8s\n",
155 "bench",
"iter",
"min",
"max",
"avg",
"std",
"sec/op",
"op/sec",
156 "block_size",
"time_in_sec",
"bytes",
"KiB",
"BW_KiB",
"IOPS");
157 for (
set =
last;
set !=
NULL;
set =
set->us_prev) {
158 printf(
"set: %s\n", set->us_name);
159 for (bench = &set->us_run[0]; bench->
ub_name; ++bench) {
161 std = sqrt(bench->
ub_square / round - avg * avg);
167 iops = (bw_kibps * 1024) / kbs_per_op;
170 printf(
"\t%12.12s: [%7i] %6.2f %6.2f %6.2f %5.2f%%" 175 std * 100.0 / avg, avg / bench->
ub_iter,
177 bench->
ub_total, bytes, kib, bw_kibps, iops);
182 M0_INTERNAL
int m0_ub_run(uint32_t rounds,
const char *opts)
189 for (
set =
last;
set !=
NULL;
set =
set->us_prev) {
190 for (bench = &set->us_run[0]; bench->
ub_name; ++bench) {
198 for (round = 1; round <= rounds; ++round) {
199 printf(
"-- round %"PRIu32" --\n", round);
200 for (
set =
last;
set !=
NULL;
set =
set->us_prev) {
201 printf(
" %s[", set->us_name);
202 if (set->us_init !=
NULL) {
203 rc =
set->us_init(opts);
207 for (bench = &set->us_run[0]; bench->
ub_name; ++bench)
209 if (set->us_fini !=
NULL)
218 fprintf(stderr,
"Benchmark initialisation failed: `%s'," 219 " rc=%d\n", set->us_name,
rc);
static void results_print(uint32_t round)
static int(* diff[M0_PARITY_CAL_ALGO_NR])(struct m0_parity_math *math, struct m0_buf *old, struct m0_buf *new, struct m0_buf *parity, uint32_t index)
#define min_type(t, a, b)
void(* ub_round)(int iter)
uint32_t ub_blocks_per_op
static void timeval_diff(const struct timeval *start, const struct timeval *end, struct timeval *diff)
static struct m0_ub_set * last
static double delay(const struct timeval *start, const struct timeval *end)
M0_INTERNAL int m0_ub_run(uint32_t rounds, const char *opts)
static uint64_t bw(uint64_t bytes, m0_time_t time)
m0_time_t m0_time_now(void)
static struct m0_thread t[8]
struct m0_ub_set * us_prev
M0_INTERNAL int m0_ub_set_select(const char *name)
M0_INTERNAL void m0_ub_set_print(void)
static void timeval_norm(struct timeval *t)
m0_time_t m0_time_sub(const m0_time_t t1, const m0_time_t t2)
static int start(struct m0_fom *fom)
#define max_type(t, a, b)
M0_INTERNAL void m0_ub_set_add(struct m0_ub_set *set)
static void ub_run_one(const struct m0_ub_set *set, struct m0_ub_bench *bench)