diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | Makefile | 29 | ||||
| -rw-r--r-- | src/example.cpp | 10 |
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(); |