diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7448584 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +TARGETS = c++ rust zig-safe zig-fast c +RUNS ?= 3 + +.PHONY: all +all: $(TARGETS) + +.PHONY: benchmark +benchmark: all + hyperfine -r$(RUNS) $(foreach TARGET,$(TARGETS),./$(TARGET)) + +c: c.c + clang -stdlib=libgcc -O3 $< -o $@ + +c++: c++.cpp + clang++ -stdlib=libstdc++ -O3 $< -o $@ + +rust: rust.rs + rustc -C opt-level=3 $< + +zig-safe: zig.zig + zig build-exe $< -target x86_64-linux -O ReleaseSafe --name $@ + +zig-fast: zig.zig + zig build-exe $< -target x86_64-linux -O ReleaseFast --name $@ diff --git a/readme.md b/readme.md index 007b01c..f697f9c 100644 --- a/readme.md +++ b/readme.md @@ -37,7 +37,7 @@ cccccccc;.:odl:.;cccccccccccccc:,. CPU: 11th Gen Intel i5-11400H (12) @ 4. Now, these are the results: ``` -$ clang++ -stdlib=libstdc++ -O3 c++.cpp +$ clang++ -stdlib=libstdc++ -O3 c++.cpp -o c++ $ time ./c++ The result is 9999999999 real 1m59.314s @@ -55,8 +55,8 @@ sys 0m0.002s ``` ``` -$ zig build-exe zig.zig -target x86_64-linux -O ReleaseSafe -$ time ./zig +$ zig build-exe zig.zig -target x86_64-linux -O ReleaseSafe --name zig-safe +$ time ./zig-safe The result is 9999999999 real 1m38.193s @@ -65,8 +65,8 @@ sys 0m0.003s ``` ``` -$ zig build-exe zig.zig -target x86_64-linux -O ReleaseFast -$ time ./zig +$ zig build-exe zig.zig -target x86_64-linux -O ReleaseFast --name zig-fast +$ time ./zig-fast The result is 9999999999 real 1m56.232s @@ -75,7 +75,7 @@ sys 0m0.003s ``` ``` -$ clang -stdlib=libgcc -O3 c.c +$ clang -stdlib=libgcc -O3 c.c -o c $ time ./c The result is 9999999999 real 1m58.715s