This commit is contained in:
Gregory Burd 2024-04-10 23:23:02 -04:00
parent 5460ef87b7
commit 5d5c7f1584
2 changed files with 22 additions and 19 deletions

View file

@ -27,8 +27,9 @@ tsc(void)
return ((uint64_t)high << 32) | low; return ((uint64_t)high << 32) | low;
} }
static static uint64_t
uint64_t get_tsc_frequency() { get_tsc_frequency()
{
uint32_t high, low; uint32_t high, low;
__asm__ volatile("rdtsc" : "=a"(low), "=d"(high)); __asm__ volatile("rdtsc" : "=a"(low), "=d"(high));
__asm__ volatile("rdtsc"); __asm__ volatile("rdtsc");
@ -36,7 +37,8 @@ uint64_t get_tsc_frequency() {
} }
double double
tsc_ticks_to_ns(uint64_t tsc_ticks) { tsc_ticks_to_ns(uint64_t tsc_ticks)
{
static uint64_t tsc_freq = 0; static uint64_t tsc_freq = 0;
if (tsc_freq == 0) { if (tsc_freq == 0) {
tsc_freq = get_tsc_frequency(); tsc_freq = get_tsc_frequency();

View file

@ -696,8 +696,8 @@ test_perf_span_solo(const MunitParameter params[], void *data)
} }
} }
uint64_t est = EST_MEDIAN_GET(solo); uint64_t est = EST_MEDIAN_GET(solo);
fprintf(stdout, "median time %zu or %f ns\n", est, tsc_ticks_to_ns(est)); // measured 228 // fprintf(stdout, "median time %zu or %f ns\n", est, tsc_ticks_to_ns(est)); // measured 228
assert_true(EST_MEDIAN_GET(solo) < 500); assert_true(est < 500);
fflush(stdout); fflush(stdout);
return MUNIT_OK; return MUNIT_OK;
@ -751,7 +751,8 @@ test_perf_span_tainted(const MunitParameter params[], void *data)
} }
} }
uint64_t est = EST_MEDIAN_GET(tainted); uint64_t est = EST_MEDIAN_GET(tainted);
fprintf(stdout, "median time %zu or %f ns\n", est, tsc_ticks_to_ns(est)); // measured 228 // fprintf(stdout, "median time %zu or %f ns\n", est, tsc_ticks_to_ns(est)); // measured 228
assert_true(est < 500);
return MUNIT_OK; return MUNIT_OK;
} }