blob: 7fd06d196d7ce05ed8480423ad92ea5dd6dcde09 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include <gmp.h>
// Minimal implementations for benchmarking
typedef uint64_t c3_d;
typedef uint32_t c3_w;
typedef uint8_t c3_y;
typedef uint64_t u3_noun;
// Simple noun construction (direct/indirect atoms and cells)
#define u3r_mug(x) 0 // Dummy for now
static inline u3_noun u3nc(u3_noun a, u3_noun b) {
// Allocate cell (simplified - just store as tagged pointer)
u3_noun* cell = malloc(sizeof(u3_noun) * 2);
cell[0] = a;
cell[1] = b;
return ((u3_noun)cell) | 1; // Tag as cell
}
static inline void u3z(u3_noun a) {
if (a > 0 && (a & 1)) {
free((void*)(a & ~1));
}
}
// Timing utilities
static double get_time() {
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec + tv.tv_usec / 1000000.0;
}
// Benchmark a function
static void benchmark(const char* name, int iterations, void (*f)(void)) {
// Warmup
int warmup = iterations / 10;
if (warmup > 100) warmup = 100;
for (int i = 0; i < warmup; i++) {
f();
}
// Actual benchmark
double start = get_time();
for (int i = 0; i < iterations; i++) {
f();
}
double elapsed = get_time() - start;
double avg = elapsed / iterations;
printf("%-40s %d iters: avg=%.6f total=%.6f\n", name, iterations, avg, elapsed);
}
int main() {
printf("========================================\n");
printf("Simplified Jam/Cue Benchmark (C)\n");
printf("========================================\n\n");
printf("NOTE: Full vere integration benchmark requires complex build setup.\n");
printf("For accurate C comparison, use vere's existing test infrastructure.\n");
printf("OCaml benchmarks are self-contained and ready to compare!\n");
printf("\n========================================\n");
return 0;
}
|