1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (C) 2017 Intel Corporation. 3 * All rights reserved. 4 */ 5 6 #include "spdk/stdinc.h" 7 8 #include "spdk/env.h" 9 #include "spdk/util.h" 10 #include "spdk/histogram_data.h" 11 12 /* 13 * This applications is a simple test app used to test the performance of 14 * tallying datapoints with struct spdk_histogram_data. It can be used 15 * to measure the effect of changes to the spdk_histogram_data implementation. 16 * 17 * There are no command line parameters currently - it just tallies 18 * datapoints for 10 seconds in a default-sized histogram structure and 19 * then prints out the number of tallies performed. 20 */ 21 22 static void 23 usage(const char *prog) 24 { 25 printf("usage: %s\n", prog); 26 printf("Options:\n"); 27 } 28 29 int 30 main(int argc, char **argv) 31 { 32 struct spdk_histogram_data *h; 33 struct spdk_env_opts opts; 34 uint64_t tsc[128], t, end_tsc, count; 35 uint32_t i; 36 int ch; 37 int rc = 0; 38 39 while ((ch = getopt(argc, argv, "")) != -1) { 40 switch (ch) { 41 default: 42 usage(argv[0]); 43 return 1; 44 } 45 } 46 47 spdk_env_opts_init(&opts); 48 if (spdk_env_init(&opts)) { 49 printf("Err: Unable to initialize SPDK env\n"); 50 return 1; 51 } 52 53 for (i = 0; i < SPDK_COUNTOF(tsc); i++) { 54 tsc[i] = spdk_get_ticks(); 55 } 56 57 end_tsc = spdk_get_ticks() + (10 * spdk_get_ticks_hz()); 58 count = 0; 59 h = spdk_histogram_data_alloc(); 60 61 while (true) { 62 t = spdk_get_ticks(); 63 spdk_histogram_data_tally(h, t - tsc[count % 128]); 64 count++; 65 if (t > end_tsc) { 66 break; 67 } 68 } 69 70 printf("count = %ju\n", count); 71 spdk_histogram_data_free(h); 72 73 spdk_env_fini(); 74 return rc; 75 } 76