summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Ilvokhin <d@ilvokhin.com>2025-08-26 22:19:54 +0100
committerDmitry Ilvokhin <d@ilvokhin.com>2025-08-26 22:19:54 +0100
commitd10b4c21779344acd57a60b059a941e4ebdf2b01 (patch)
tree39c7a82b9355533b56a107bea8e0f3ce061a090a
downloadbenchmarks-d10b4c21779344acd57a60b059a941e4ebdf2b01.tar.gz
benchmarks-d10b4c21779344acd57a60b059a941e4ebdf2b01.tar.bz2
benchmarks-d10b4c21779344acd57a60b059a941e4ebdf2b01.zip
Initial commit
Make stub files for C++ benchmarks.
-rw-r--r--.gitignore1
-rw-r--r--Makefile29
-rw-r--r--src/example.cpp10
3 files changed, 40 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+bin
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..8428e96
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,29 @@
+CXX=c++
+CXXFLAGS=-std=c++20 -pedantic -Wall -O3
+LDFLAGS=-lbenchmark
+
+BIN=bin
+SOURCE=src
+
+OS=$(shell uname)
+ifeq ($(OS),Darwin)
+ HOMEBREW=$(shell brew --prefix 2>/dev/null)
+ CXXFLAGS+=-I$(HOMEBREW)/include
+ LDFLAGS+=-L$(HOMEBREW)/lib
+endif
+
+SOURCES=$(wildcard $(SOURCE)/*.cpp)
+BINARIES=$(patsubst $(SOURCE)/%.cpp,$(BIN)/%,$(SOURCES))
+
+.PHONY: all clean
+
+all: $(BINARIES)
+
+$(BIN)/%: $(SOURCE)/%.cpp $(BIN)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) $< -o $@
+
+$(BIN):
+ mkdir $(BIN)
+
+clean:
+ rm -rf $(BINARIES)
diff --git a/src/example.cpp b/src/example.cpp
new file mode 100644
index 0000000..60ddf1f
--- /dev/null
+++ b/src/example.cpp
@@ -0,0 +1,10 @@
+#include <benchmark/benchmark.h>
+
+static void BM_Noop(benchmark::State& state) {
+ for (auto _ : state) {
+ __asm__("nop");
+ }
+}
+BENCHMARK(BM_Noop);
+
+BENCHMARK_MAIN();