Created
April 3, 2019 05:04
-
-
Save azat/2168ee8cc3a29397be63dcf9894f7075 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <event2/event.h> | |
| #include <event2/util.h> | |
| #include <stdlib.h> | |
| int main(int argc, char **argv) | |
| { | |
| struct timeval tv; | |
| size_t n = argc == 2 ? atoll(argv[1]) : 1<<20; | |
| struct event_base *base = event_base_new(); | |
| for (size_t i = 0; i < n; ++i) { | |
| #ifdef CACHED | |
| event_base_gettimeofday_cached(base, &tv); | |
| #else | |
| evutil_gettimeofday(&tv, 0); | |
| #endif | |
| } | |
| return 0; | |
| } |
Author
azat
commented
Apr 3, 2019
Author
$ gcc -levent_core -O3 /tmp/le-gettimeofday.c
$ perf stat ./a.out $((20<<20))
Performance counter stats for './a.out 20971520':
378.13 msec task-clock # 0.999 CPUs utilized
1 context-switches # 0.003 K/sec
0 cpu-migrations # 0.000 K/sec
67 page-faults # 0.177 K/sec
1,240,030,026 cycles # 3.279 GHz
1,637,903,082 instructions # 1.32 insn per cycle
294,022,433 branches # 777.577 M/sec
13,187 branch-misses # 0.00% of all branches
0.378598087 seconds time elapsed
0.375123000 seconds user
0.003309000 seconds sys
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment