-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (49 loc) · 2.11 KB
/
Makefile
File metadata and controls
63 lines (49 loc) · 2.11 KB
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
.PHONY: clean trie_lib_so all
CPPC = g++
CPP_CFLAGS = -O3 -Wall -Werror -Wextra -std=c++11
python = python3.11
pybind_includes = $(shell ${python} -m pybind11 --includes)
ext = $(shell ${python}-config --extension-suffix)
clean:
@rm -rf build
build/libtrie.a: trie/trie.cpp
@mkdir -p build
@echo "Building trie static library"
$(CPPC) $(CPP_CFLAGS) -c trie/trie.cpp -o build/trie.o
@ar -rc $@ build/trie.o
@echo ""
build/include/trie.h: trie/trie.h
@mkdir -p build/include
@cp trie/trie.h $@
trie_lib_so: build/libtrie.a build/include/trie.h
@echo "Building bindings shared library"
$(CPPC) $(CPP_CFLAGS) -shared bindings/trie.cpp build/libtrie.a -I build/include/ $(pybind_includes) -fPIC -o build/trie$(ext)
@echo ""
build/bin/benchmark: build/libtrie.a build/include/trie.h
@echo "Building benchmark executable"
@mkdir -p build/bin/
$(CPPC) $(CPP_CFLAGS) benchmarks/cpp/benchmark.cpp build/libtrie.a -I build/include/ -o $@
@echo ""
rockyou.txt:
@wget https://github.com/kkrypt0nn/wordlists/raw/main/wordlists/famous/rockyou.zip -O rockyou.zip
@unzip -o rockyou.zip
@rm rockyou.zip
cpp_benchmark: rockyou.txt build/bin/benchmark
@echo "====== CPP benchmark ======"
@build/bin/benchmark rockyou.txt
@echo ""
python_bindings_benchmark:
@echo "====== Python benchmark - bindings ======"
@export PYTHONPATH=build/:${PYTHONPATH} && $(python) benchmarks/python/benchmark.py --words rockyou.txt --implementation cpp --words-encoding latin-1
@echo ""
python_bindings_batch_insert_benchmark:
@echo "====== Python benchmark - bindings, batch insert ======"
@export PYTHONPATH=build/:${PYTHONPATH} && $(python) benchmarks/python/benchmark.py --words rockyou.txt --implementation cpp --words-encoding latin-1 --use-batch-insert
@echo ""
pure_python_benchmark:
@echo "====== Python benchmark - Python baseline ======"
@export PYTHONPATH=build/:${PYTHONPATH} && $(python) benchmarks/python/benchmark.py --words rockyou.txt --implementation python --words-encoding latin-1
@echo ""
run_benchmarks: cpp_benchmark python_bindings_benchmark pure_python_benchmark
build: trie_lib_so
all: trie_lib_so build/bin/benchmark run_benchmarks