fix(bench): separate vlibc-under-test TU from host harness TUs
This commit is contained in:
@@ -5,16 +5,29 @@
|
||||
* This stub times vlibc_version() and is the skeleton that per-component
|
||||
* benchmarks build on. Reconfigure with --with-libc=musl or --with-libc=glibc
|
||||
* to link the same harness against a reference libc for comparison.
|
||||
*
|
||||
* This TU is deliberately a HOST-headers-only translation unit: it includes
|
||||
* no vlibc header, because vlibc's self-contained
|
||||
* <stdarg.h>/<stddef.h>/<limits.h>/<float.h> shadow GCC's internal headers
|
||||
* and mixing them with the system <stdio.h>/<time.h> hard-errors. The
|
||||
* function under test is reached through the adapter TU
|
||||
* bench_vlibc_under.c, which is compiled with vlibc's headers and exposes
|
||||
* the call through its own declaration here.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <vlibc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
/* Adapter entry (bench_vlibc_under.c); declared here rather than including
|
||||
* <vlibc.h>, which this host-header TU must not do. The adapter also drops
|
||||
* vlibc_version()'s __attribute__((const)), so the timed loop really
|
||||
* executes the call. */
|
||||
const char *
|
||||
bench_vlibc_version(void);
|
||||
|
||||
#define ITERATIONS 100000000ULL
|
||||
|
||||
int
|
||||
@@ -34,7 +47,7 @@ main(void)
|
||||
|
||||
for (unsigned long long i = 0; i < ITERATIONS; i++)
|
||||
{
|
||||
version = vlibc_version();
|
||||
version = bench_vlibc_version();
|
||||
}
|
||||
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &end) != 0)
|
||||
@@ -49,5 +62,13 @@ main(void)
|
||||
printf("vlibc_version() x %llu: %.3f s (%.2f ns/call), version=%s\n", ITERATIONS, seconds,
|
||||
seconds * 1000000000.0 / ITERATIONS, (const char *)version);
|
||||
|
||||
/*
|
||||
* Explicit flush: this harness is a host program, but its DT_NEEDED order
|
||||
* puts libvlibc.so before libc.so.6, so the exit() that runs at process
|
||||
* end is vlibc's — which does not flush stdio yet (that hook lands with
|
||||
* the stdio todo). Without the flush the buffered result above is lost.
|
||||
*/
|
||||
fflush(stdout);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user