Add smoke test and benchmarks
smoke links crt0.o + libc.a with -nostdlib -static and proves the whole chain runs without the dynamic linker; bench_strlen and bench_syscall measure the string core and raw syscall round-trip cost via make bench. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <[email protected]>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* bench_strlen.c — how fast is our string core?
|
||||
*
|
||||
* Measures strlen() over a typical short string. 10M iterations keeps
|
||||
* the loop overhead negligible; results are printed as ns per call.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "bench.h"
|
||||
|
||||
#define ITERS 10000000UL
|
||||
|
||||
int main(void)
|
||||
{
|
||||
static const char s[] = "the quick brown fox jumps over the lazy dog";
|
||||
volatile size_t sink = 0;
|
||||
long long t0, t1;
|
||||
|
||||
t0 = bench_now_ns();
|
||||
for (unsigned long i = 0; i < ITERS; i++)
|
||||
sink += strlen(s);
|
||||
t1 = bench_now_ns();
|
||||
|
||||
(void)sink; /* keep the loop observable */
|
||||
bench_print_u64((unsigned long long)((t1 - t0) / ITERS));
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user