mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Print warning when microbenchmarking w/ powersave
RDTSC on Linux has so much jitter when the CPU is in powersave mode causing things like microbenchmarks to have a 1000% margin of error
This commit is contained in:
parent
41c86fe86b
commit
c6d8e516b2
5 changed files with 64 additions and 4 deletions
|
@ -21,6 +21,7 @@
|
|||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/calls/syscall_support-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/nexgen32e/rdtsc.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
|
@ -49,7 +50,19 @@ BENCH(clock_gettime, bench) {
|
|||
EZBENCH2("nowl", donothing, nowl());
|
||||
EZBENCH2("rdtsc", donothing, rdtsc());
|
||||
EZBENCH2("gettimeofday", donothing, gettimeofday(&tv, 0));
|
||||
EZBENCH2("clock_gettime", donothing, clock_gettime(0, &ts));
|
||||
EZBENCH2("__clock_gettime", donothing, __clock_gettime(0, &ts));
|
||||
EZBENCH2("sys_clock_gettime", donothing, sys_clock_gettime(0, &ts));
|
||||
EZBENCH2("clock_gettime 0", donothing, clock_gettime(0, &ts));
|
||||
EZBENCH2("clock_gettime 1", donothing, clock_gettime(1, &ts));
|
||||
EZBENCH2("clock_gettime 4", donothing, clock_gettime(4, &ts));
|
||||
EZBENCH2("__clock_gettime 0", donothing, __clock_gettime(0, &ts));
|
||||
EZBENCH2("__clock_gettime 1", donothing, __clock_gettime(1, &ts));
|
||||
EZBENCH2("__clock_gettime 4", donothing, __clock_gettime(4, &ts));
|
||||
if (IsWindows()) {
|
||||
EZBENCH2("sys_clock_gettime 0", donothing, sys_clock_gettime_nt(0, &ts));
|
||||
EZBENCH2("sys_clock_gettime 1", donothing, sys_clock_gettime_nt(1, &ts));
|
||||
EZBENCH2("sys_clock_gettime 4", donothing, sys_clock_gettime_nt(4, &ts));
|
||||
} else {
|
||||
EZBENCH2("sys_clock_gettime 0", donothing, sys_clock_gettime(0, &ts));
|
||||
EZBENCH2("sys_clock_gettime 1", donothing, sys_clock_gettime(1, &ts));
|
||||
EZBENCH2("sys_clock_gettime 4", donothing, sys_clock_gettime(4, &ts));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue