blob: dcd6ca328b30bdeeee8171aad1a2bdef341887e5 (
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# Makefile for Nock OCaml/C benchmark comparison
VERE_ROOT = ../vere
VERE_PKG = $(VERE_ROOT)/pkg/noun
VERE_INCLUDES = -I$(VERE_ROOT)/pkg -I$(VERE_ROOT)/ext
# Find the Vere build directory
VERE_BUILD = $(VERE_ROOT)/build
# Try to find the actual library paths
VERE_LIBS = -L$(VERE_BUILD) -L$(VERE_ROOT)/build
CC = gcc
CFLAGS = -O3 -g $(VERE_INCLUDES)
LDFLAGS = $(VERE_LIBS)
.PHONY: all clean bench bench-c bench-ocaml test compare
all: test bench
# Build everything
build: build-ocaml
build-ocaml:
@echo "Building OCaml implementation..."
dune build
# Note: C benchmark requires linking against libvere which may not be available
# as a standalone library. We'll document this limitation.
build-c: bench_nock_c
@echo "C benchmark built (requires Vere libraries)"
bench_nock_c: bench_nock.c
@echo "Note: Building C benchmark requires Vere to be built first"
@echo "This may fail if Vere libraries are not available"
@echo "Attempting to compile..."
-$(CC) $(CFLAGS) -o bench_nock_c bench_nock.c \
$(VERE_PKG)/allocate.c \
$(VERE_PKG)/nock.c \
$(VERE_PKG)/hashtable.c \
$(VERE_PKG)/imprison.c \
$(VERE_PKG)/jets.c \
$(VERE_PKG)/manage.c \
$(VERE_PKG)/retrieve.c \
$(VERE_PKG)/trace.c \
$(VERE_PKG)/xtract.c \
$(VERE_PKG)/events.c \
$(VERE_PKG)/zave.c \
$(LDFLAGS) -lm -lpthread -lgmp -lsigsegv -luv -lcrypto -lssl
# Run tests
test:
@echo "Running OCaml tests..."
dune exec ./test_nock.exe
# Run benchmarks
bench: bench-ocaml
bench-ocaml:
@echo "Running OCaml benchmark..."
dune exec ./bench_nock.exe
bench-c: bench_nock_c
@echo "Running C benchmark..."
./bench_nock_c
# Compare both implementations (if C benchmark is available)
compare: bench-ocaml
@echo ""
@echo "=================================="
@echo "Comparison (OCaml only)"
@echo "=================================="
@echo "Note: C benchmark requires full Vere build"
@echo "To compare, build Vere first, then run 'make bench-c'"
# Clean build artifacts
clean:
dune clean
rm -f bench_nock_c
rm -f *.o
help:
@echo "Nock OCaml/C Benchmark Makefile"
@echo ""
@echo "Targets:"
@echo " make test - Run OCaml tests"
@echo " make bench - Run OCaml benchmark"
@echo " make bench-ocaml - Run OCaml benchmark"
@echo " make bench-c - Run C benchmark (requires Vere build)"
@echo " make compare - Run comparison"
@echo " make clean - Clean build artifacts"
@echo ""
@echo "Note: C benchmarks require Vere to be fully built first."
|