diff options
Diffstat (limited to 'vere')
-rw-r--r-- | vere/build.zig | 10 | ||||
-rw-r--r-- | vere/pkg/vere/solid_cue_bench.c | 60 |
2 files changed, 70 insertions, 0 deletions
diff --git a/vere/build.zig b/vere/build.zig index 74375b6..def6feb 100644 --- a/vere/build.zig +++ b/vere/build.zig @@ -628,6 +628,16 @@ fn buildBinary( .deps = vere_test_deps, }, .{ + .name = "solid-cue-bench", + .file = "pkg/vere/solid_cue_bench.c", + .deps = vere_test_deps, + }, + .{ + .name = "examine-solid", + .file = "../ocaml/test/examine_solid_structure.c", + .deps = vere_test_deps, + }, + .{ .name = "newt-test", .file = "pkg/vere/newt_tests.c", .deps = vere_test_deps, diff --git a/vere/pkg/vere/solid_cue_bench.c b/vere/pkg/vere/solid_cue_bench.c new file mode 100644 index 0000000..0be36ad --- /dev/null +++ b/vere/pkg/vere/solid_cue_bench.c @@ -0,0 +1,60 @@ +/// Benchmark cue performance on solid pill + +#include <sys/stat.h> +#include <sys/time.h> +#include <stdio.h> +#include <stdlib.h> +#include "noun.h" +#include "ur/ur.h" +#include "vere.h" + +static double get_time(void) { + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_sec + tv.tv_usec / 1000000.0; +} + +int main(int argc, char* argv[]) { + const char* pill_path = argc > 1 ? argv[1] : "../../../ocaml/solid.pill"; + + // Read pill file + FILE* f = fopen(pill_path, "rb"); + if (!f) { + printf("Error: cannot open %s\n", pill_path); + return 1; + } + + struct stat st; + fstat(fileno(f), &st); + c3_d len_d = st.st_size; + + c3_y* byt_y = malloc(len_d); + fread(byt_y, 1, len_d, f); + fclose(f); + + printf("Pill: %s (%.1f MB)\n", pill_path, len_d / 1024.0 / 1024.0); + printf("Starting cue benchmark...\n\n"); + + // Initialize Urbit runtime + u3C.wag_w |= u3o_hashless; + u3m_boot_lite(1 << 26); // 64 MB loom + + // Benchmark cue + double start = get_time(); + u3_cue_xeno* sil_u = u3s_cue_xeno_init_with(ur_fib27, ur_fib28); + u3_weak pil = u3s_cue_xeno_with(sil_u, len_d, byt_y); + double elapsed = get_time() - start; + + if (u3_none == pil) { + printf("Error: cue failed\n"); + return 1; + } + + u3s_cue_xeno_done(sil_u); + + printf("✓ Cue completed in %.4f seconds\n", elapsed); + printf(" Throughput: %.2f MB/s\n", (len_d / 1024.0 / 1024.0) / elapsed); + + free(byt_y); + return 0; +} |