Skip to content
This repository was archived by the owner on Aug 13, 2019. It is now read-only.

Commit 7751bd8

Browse files
committed
chore cmd/tsdb: Refactored Makefile to use Makefile.common
Signed-off-by: Martin Chodur <[email protected]>
1 parent 27f6937 commit 7751bd8

File tree

1 file changed

+47
-9
lines changed

1 file changed

+47
-9
lines changed

cmd/tsdb/Makefile

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,49 @@
1+
# Copyright 2018 The Prometheus Authors
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
TSDB_BIN = "./tsdb"
15+
TSDB_BENCHMARK_NUM_METRICS ?= 1000
16+
TSDB_PROJECT_DIR = "../.."
17+
TSDB_BENCHMARK_DATASET ?= "$(TSDB_PROJECT_DIR)/testdata/20kseries.json"
18+
TSDB_BENCHMARK_OUTPUT_DIR ?= "./benchout"
19+
20+
STATICCHECK_IGNORE =
21+
include ../../Makefile.common
22+
23+
# Since tsdb client yet has no tests we can at least try to run benchmark
24+
test: bench
25+
126
build:
2-
@go build .
3-
4-
bench: build
27+
@$(GO) build .
28+
29+
bench: build
30+
# Check if dataset exists
31+
@test -e $(TSDB_BENCHMARK_DATASET) >/dev/null 2>&1 || (echo "ERROR: Cannot find benchmark dataset. Specify file using the TSDB_BENCHMARK_DATASET variable"; exit 1)
532
@echo ">> running benchmark"
6-
@./tsdb bench write --metrics=$(NUM_METRICS) testdata.1m
7-
@go tool pprof -svg ./tsdb benchout/cpu.prof > benchout/cpuprof.svg
8-
@go tool pprof --inuse_space -svg ./tsdb benchout/mem.prof > benchout/memprof.inuse.svg
9-
@go tool pprof --alloc_space -svg ./tsdb benchout/mem.prof > benchout/memprof.alloc.svg
10-
@go tool pprof -svg ./tsdb benchout/block.prof > benchout/blockprof.svg
11-
@go tool pprof -svg ./tsdb benchout/mutex.prof > benchout/mutexprof.svg
33+
@$(TSDB_BIN) bench write --metrics=$(TSDB_BENCHMARK_NUM_METRICS) $(TSDB_BENCHMARK_DATASET)
34+
35+
bench-vizualization: bench
36+
# Check if Graphviz is installed
37+
@command -v dot >/dev/null 2>&1 || (echo "ERROR: You need to have Graphviz installed to generate pprof visualization."; exit 1)
38+
@$(GO) tool pprof -svg ./tsdb $(TSDB_BENCHMARK_OUTPUT_DIR)/cpu.prof > $(TSDB_BENCHMARK_OUTPUT_DIR)/cpuprof.svg
39+
@$(GO) tool pprof --inuse_space -svg ./tsdb $(TSDB_BENCHMARK_OUTPUT_DIR)/mem.prof > $(TSDB_BENCHMARK_OUTPUT_DIR)/memprof.inuse.svg
40+
@$(GO) tool pprof --alloc_space -svg ./tsdb $(TSDB_BENCHMARK_OUTPUT_DIR)/mem.prof > $(TSDB_BENCHMARK_OUTPUT_DIR)/memprof.alloc.svg
41+
@$(GO) tool pprof -svg ./tsdb $(TSDB_BENCHMARK_OUTPUT_DIR)/block.prof > $(TSDB_BENCHMARK_OUTPUT_DIR)/blockprof.svg
42+
@$(GO) tool pprof -svg ./tsdb $(TSDB_BENCHMARK_OUTPUT_DIR)/mutex.prof > $(TSDB_BENCHMARK_OUTPUT_DIR)/mutexprof.svg
43+
44+
clean:
45+
# Remove built binary and benchmark results
46+
rm -f $(TSDB_BIN)
47+
rm -rf $(TSDB_BENCHMARK_OUTPUT_DIR)
48+
49+
.PHONY: clean test

0 commit comments

Comments
 (0)