Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup compile commands, add makefile #3

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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 $@
12 changes: 6 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down