]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/lib/event/reactor_perf/reactor_perf.c
4 * Copyright (c) Intel Corporation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 #include "spdk/event.h"
42 static int g_time_in_sec
;
43 static int g_queue_depth
;
44 static struct spdk_poller
*test_end_poller
;
45 static uint64_t g_call_count
= 0;
55 __submit_next(void *arg1
, void *arg2
)
57 struct spdk_event
*event
;
61 event
= spdk_event_allocate(spdk_env_get_current_core(),
62 __submit_next
, NULL
, NULL
);
63 spdk_event_call(event
);
67 test_start(void *arg1
, void *arg2
)
71 printf("test_start\n");
73 /* Register a poller that will stop the test after the time has elapsed. */
74 spdk_poller_register(&test_end_poller
, __test_end
, NULL
,
75 spdk_env_get_current_core(),
76 g_time_in_sec
* 1000000ULL);
78 for (i
= 0; i
< g_queue_depth
; i
++) {
79 __submit_next(NULL
, NULL
);
86 printf("test_abort\n");
88 spdk_poller_unregister(&test_end_poller
, NULL
);
93 usage(const char *program_name
)
95 printf("%s options\n", program_name
);
96 printf("\t[-d Allowed delay when passing messages between cores in microseconds]\n");
97 printf("\t[-q Queue depth (default: 1)]\n");
98 printf("\t[-t time in seconds]\n");
102 main(int argc
, char **argv
)
104 struct spdk_app_opts opts
;
107 spdk_app_opts_init(&opts
);
108 opts
.name
= "reactor_perf";
109 opts
.max_delay_us
= 1000;
114 while ((op
= getopt(argc
, argv
, "d:q:t:")) != -1) {
117 opts
.max_delay_us
= atoi(optarg
);
120 g_queue_depth
= atoi(optarg
);
123 g_time_in_sec
= atoi(optarg
);
131 if (!g_time_in_sec
) {
138 opts
.shutdown_cb
= test_cleanup
;
140 spdk_app_init(&opts
);
142 spdk_app_start(test_start
, NULL
, NULL
);
146 printf("Performance: %8ju events per second\n", g_call_count
/ g_time_in_sec
);