Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.

Commit d823d44

Browse files
committed
Added profiling for cancelling events
1 parent c3e6189 commit d823d44

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/prof.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,40 @@ void equeue_dispatch_many_prof(int count) {
274274
equeue_destroy(&q);
275275
}
276276

277+
void event_cancel_prof(void) {
278+
struct equeue q;
279+
equeue_create(&q, 2*sizeof(struct event));
280+
281+
prof_loop() {
282+
int id = event_call(&q, no_func, 0);
283+
284+
prof_start();
285+
event_cancel(&q, id);
286+
prof_stop();
287+
}
288+
289+
equeue_destroy(&q);
290+
}
291+
292+
void event_cancel_many_prof(int count) {
293+
struct equeue q;
294+
equeue_create(&q, 2*count*sizeof(struct event));
295+
296+
for (int i = 0; i < count; i++) {
297+
event_call(&q, no_func, 0);
298+
}
299+
300+
prof_loop() {
301+
int id = event_call(&q, no_func, 0);
302+
303+
prof_start();
304+
event_cancel(&q, id);
305+
prof_stop();
306+
}
307+
308+
equeue_destroy(&q);
309+
}
310+
277311
void event_alloc_size_prof(void) {
278312
size_t size = 2*32*sizeof(struct event);
279313

@@ -346,11 +380,13 @@ int main() {
346380
prof_measure(event_post_prof);
347381
prof_measure(event_post_future_prof);
348382
prof_measure(equeue_dispatch_prof);
383+
prof_measure(event_cancel_prof);
349384

350385
prof_measure(event_alloc_many_prof, 1000);
351386
prof_measure(event_post_many_prof, 1000);
352387
prof_measure(event_post_future_many_prof, 1000);
353388
prof_measure(equeue_dispatch_many_prof, 100);
389+
prof_measure(event_cancel_many_prof, 100);
354390

355391
prof_measure(event_alloc_size_prof);
356392
prof_measure(event_alloc_many_size_prof, 1000);

0 commit comments

Comments
 (0)