aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: c097d9b6a3dac240676ff9ce5c2e7cbb38da29c0 (plain)
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
.PHONY: help
help: # HELP: This output
	@awk -F: '/HELP: [A-Za-z]/{print "\033[1m" $$1 "\033[0m:" $$3}' Makefile

.PHONY: format
format: # HELP: Format every file in the project
	@cargo fmt

.PHONY: server
server: # HELP: Start the server
	@cargo run server

.PHONY: server.debug
server.debug: # HELP: Start the server with log level set to "debug"
	@RUST_LOG=debug cargo run server

.PHONY: server.daemon
server.daemon: # HELP: Start the server in the background
	@cargo run server > /dev/null &
	@sleep 1

.PHONY: test
test: server.daemon # HELP: Run the tests
	@awk -v RS= '{print $$0; system("sleep .1")}' query.bl | nc 127.0.0.1 4902 > result
	@diff -c expected result
	@killall blom

.PHONY: server.seed
server.seed: # HELP: Seed the server with some IP blocks
	@awk '{print "SET "$$0" Foo"}' samples/ip-prefixes | xargs -I{} -n1 -P8 ./target/release/blom query "{}"

.PHONY: server.seed.tiny
server.seed.tiny: # HELP: Seed the server with less IP blocks
	@head -n20 samples/ip-prefixes | awk '{print "SET "$$0" Foo"}' | xargs -I{} ./target/release/blom query "{}"

.PHONY: flamegraph
flamegraph: # HELP: Generate a flamegraph
	@CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph -- server > /dev/null &
	@sleep 1
	@awk '{print "SET "$$0" Foo"}' samples/ip-prefixes | xargs -I{} -n1 -P8 ./target/release/blom query "{}" > /dev/null
	@killall blom

.PHONY: memprof
memprof: # HELP: Generate a memory profile
	@cargo build --release --features debug-logs
	@env MEMORY_PROFILER_LOG=warn LD_PRELOAD=./bin/libbytehound.so ./target/release/blom server > /dev/null &
	@sleep 1
	@awk '{print "SET "$$0" Foo"}' samples/ip-prefixes | xargs -I{} -n1 -P8 ./target/release/blom query "{}" > /dev/null
	@killall blom
	@./bin/bytehound server memory-profiling_*.dat