Skip to content

Commit 3eaef40

Browse files
committed
Add bm_cleos_cmd.sh && Set project version
1 parent 85e790e commit 3eaef40

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
cmake_minimum_required( VERSION 3.14 )
2-
project( ack )
2+
project(
3+
ack
4+
LANGUAGES CXX
5+
VERSION 0.1.0
6+
)
37

48
option( ACK_NO_INTRINSICS "Don't use intrinsics" OFF )
59
option( ACK_BUILD_TESTS "Build tests" ON )

scripts/bm_cleos_cmd.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
# Banchmark script for cleos command
3+
# usage:
4+
# bm_cleos_cmd.sh "<cleos_command>" N-iterations
5+
6+
script_name="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")"
7+
sleep_time=3
8+
9+
print_help() {
10+
echo "Usage:"
11+
echo -e " ${script_name} <command> N-iterations\n"
12+
}
13+
14+
if [[ $# -lt 2 ]]; then
15+
echo "Error: invalid number of arguments!" >&2
16+
print_help
17+
exit 1
18+
fi
19+
20+
command=$1
21+
iterations=$2
22+
23+
re='^[0-9]+$'
24+
if ! [[ $iterations =~ $re ]] ; then
25+
echo "Error: iteration argument is not a number!" >&2
26+
print_help
27+
exit 1;
28+
fi
29+
30+
sum_cpu_usage_us=0
31+
for (( i = 0; i < $iterations; i++ ))
32+
do
33+
result=$($command -j)
34+
rc=$?; if [[ $rc != 0 ]]; then echo -e "Error: An error occored while executing command!\n${result}"; exit $rc; fi
35+
cpu_usage_us=$(echo $result | jq -r ".processed.receipt.cpu_usage_us")
36+
if [ "$cpu_usage_us" != "<unknown>" ]; then
37+
sum_cpu_usage_us=$(expr $sum_cpu_usage_us + $cpu_usage_us)
38+
fi
39+
sleep $sleep_time
40+
done;
41+
42+
echo "avg. CPU usage: $(expr $sum_cpu_usage_us / $iterations)us"

0 commit comments

Comments
 (0)