Skip to content

Commit

Permalink
collect cpu/mem statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
Trisfald committed Jul 23, 2020
1 parent 9c4b8cc commit d2b05df
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
2 changes: 2 additions & 0 deletions bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

RESULT_DIR=results/$(date "+%y%d%mT%H%M%S")

docker pull infoblox/ghz:0.0.1

# Rust Tonic benchmark
./run_single_bench.sh rust_tonic_test "${RESULT_DIR}"

Expand Down
16 changes: 16 additions & 0 deletions collect_stats.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

NAME=$1
REPORT_DIR=${2:-"results"}

rm -f "${REPORT_DIR}"/"${NAME}".stats

sleep 1

while true; do
(docker stats \
--no-stream \
--format "table {{.CPUPerc}}\t{{.MemUsage}}" \
"${NAME}" | grep -v CPU) >> "${REPORT_DIR}"/"${NAME}".stats 2> /dev/null || break;
sleep 5 || break;
done
23 changes: 16 additions & 7 deletions run_single_bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,30 @@ GRPC_BENCHMARK_DURATION=${GRPC_BENCHMARK_DURATION:-"30s"}
GRPC_SERVER_CPUS=${GRPC_SERVER_CPUS:-"1"}

echo "==> Running benchmark for ${NAME}..."

mkdir -p "${REPORT_DIR}"

docker run --name "${NAME}" --rm --cpus "${GRPC_SERVER_CPUS}" --network=host -d -t ${NAME}

sleep 5

./collect_stats.sh "${NAME}" "${REPORT_DIR}" &

docker run \
--name ghz \
--rm \
--network=host \
-v "${PWD}"/proto:/proto:ro \
--entrypoint=ghz \
infoblox/ghz:0.0.1 \
--proto=/proto/helloworld/helloworld.proto \
--call=helloworld.Greeter.SayHello \
--insecure \
--connections=5 \
--duration "${GRPC_BENCHMARK_DURATION}" \
-d "{\"name\":\"it's not as performant as we expected\"}" \
127.0.0.1:50051 > "${REPORT_DIR}"/"${NAME}".report
--proto=/proto/helloworld/helloworld.proto \
--call=helloworld.Greeter.SayHello \
--insecure \
--connections=5 \
--duration "${GRPC_BENCHMARK_DURATION}" \
-d "{\"name\":\"it's not as performant as we expected\"}" \
127.0.0.1:50051 > "${REPORT_DIR}"/"${NAME}".report

kill -INT %1 2> /dev/null

docker container stop "${NAME}"

0 comments on commit d2b05df

Please sign in to comment.