mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 08:48: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
|
@ -19,6 +19,7 @@
|
|||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/time/time.h"
|
||||
|
@ -28,10 +29,11 @@ STATIC_YOINK("strnwidth");
|
|||
|
||||
void __testlib_ezbenchreport(const char *form, uint64_t c1, uint64_t c2) {
|
||||
uint64_t ns1, ns2;
|
||||
__warn_if_powersave();
|
||||
ns1 = rintl(ConvertTicksToNanos(c1));
|
||||
ns2 = rintl(ConvertTicksToNanos(c2));
|
||||
(fprintf)(stderr,
|
||||
VEIL("r", " * %-19s l: %,9lu𝑐 %,9lu𝑛𝑠 m: %,9lu𝑐 %,9lu𝑛𝑠\n"),
|
||||
VEIL("r", " * %-19s l: %,9luc %,9luns m: %,9luc %,9luns\n"),
|
||||
form, c1, ns1, c2, ns2);
|
||||
}
|
||||
|
||||
|
@ -39,6 +41,7 @@ void __testlib_ezbenchreport_n(const char *form, char z, size_t n, uint64_t c) {
|
|||
char msg[128];
|
||||
uint64_t bps;
|
||||
long double cn, lat;
|
||||
__warn_if_powersave();
|
||||
(snprintf)(msg, sizeof(msg), "%s %c=%d", form, z, n);
|
||||
cn = ConvertTicksToNanos(c);
|
||||
if (!n) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue