aboutsummaryrefslogtreecommitdiff
path: root/contrib/benchmark/collect.awk
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/benchmark/collect.awk')
-rw-r--r--contrib/benchmark/collect.awk58
1 files changed, 58 insertions, 0 deletions
diff --git a/contrib/benchmark/collect.awk b/contrib/benchmark/collect.awk
new file mode 100644
index 000000000..887886abf
--- /dev/null
+++ b/contrib/benchmark/collect.awk
@@ -0,0 +1,58 @@
1# This file is part of GNUnet
2# Copyright (C) 2018 GNUnet e.V.
3#
4# GNUnet is free software: you can redistribute it and/or modify it
5# under the terms of the GNU Affero General Public License as published
6# by the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# GNUnet is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12# Affero General Public License for more details.
13#
14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
18# Aggregate benchmarking data from multiple threads/processes
19# generated by util/benchmark.c.
20#
21# Can be used as
22# awk -f collect.awk gnunet-benchmark-{ops,urls}-*.txt
23
24
25# records are of the following forms:
26# op <op> count <count> time_us <time_us>
27# url <url> status <status> count <count> time_us <time_us>
28{
29 if ($1 == "op") {
30 op[$2]["count"] += $4;
31 op[$2]["time_us"] += $6;
32 } else if ($1 == "url") {
33 url[$2][$4]["count"] += $6;
34 url[$2][$4]["time_us"] += $8;
35 }
36}
37
38function avg(s, c) {
39 if (c == 0) {
40 return 0;
41 } else {
42 return s / c;
43 }
44}
45
46END {
47 for (x in op) {
48 print "op", x, "count", op[x]["count"], "time_us", op[x]["time_us"], \
49 "time_avg_us", avg(op[x]["time_us"], op[x]["count"]);
50 }
51 for (x in url) {
52 for (y in url[x]) {
53 print "url", x, "status", y, \
54 "count", url[x][y]["count"], "time_us", url[x][y]["time_us"], \
55 "time_avg_us", avg(url[x][y]["time_us"], url[x][y]["count"]);
56 }
57 }
58}