Branch data Line data Source code
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 : 0 : usage(const char *prog) 24 : : { 25 [ # # ]: 0 : printf("usage: %s\n", prog); 26 [ # # ]: 0 : printf("Options:\n"); 27 : 0 : } 28 : : 29 : : int 30 : 0 : main(int argc, char **argv) 31 : : { 32 : : struct spdk_histogram_data *h; 33 : 0 : struct spdk_env_opts opts; 34 : 0 : uint64_t tsc[128], t, end_tsc, count; 35 : : uint32_t i; 36 : : int ch; 37 : 0 : int rc = 0; 38 : : 39 [ # # # # : 0 : while ((ch = getopt(argc, argv, "")) != -1) { # # ] 40 : : switch (ch) { 41 : 0 : default: 42 : 0 : usage(argv[0]); 43 : 0 : return 1; 44 : : } 45 : : } 46 : : 47 : 0 : spdk_env_opts_init_ext(&opts, sizeof(opts)); 48 [ # # ]: 0 : if (spdk_env_init_ext(&opts)) { 49 [ # # ]: 0 : printf("Err: Unable to initialize SPDK env\n"); 50 : 0 : return 1; 51 : : } 52 : : 53 [ # # ]: 0 : for (i = 0; i < SPDK_COUNTOF(tsc); i++) { 54 : 0 : tsc[i] = spdk_get_ticks(); 55 : : } 56 : : 57 : 0 : end_tsc = spdk_get_ticks() + (10 * spdk_get_ticks_hz()); 58 : 0 : count = 0; 59 : 0 : h = spdk_histogram_data_alloc(); 60 : : 61 : : while (true) { 62 : 0 : t = spdk_get_ticks(); 63 : 0 : spdk_histogram_data_tally(h, t - tsc[count % 128]); 64 : 0 : count++; 65 [ # # ]: 0 : if (t > end_tsc) { 66 : 0 : break; 67 : : } 68 : : } 69 : : 70 [ # # ]: 0 : printf("count = %ju\n", count); 71 : 0 : spdk_histogram_data_free(h); 72 : : 73 : 0 : spdk_env_fini(); 74 : 0 : return rc; 75 : : }