1 # This file is part of GNUnet
2 # Copyright (C) 2018 GNUnet e.V.
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.
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.
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/>.
17 # SPDX-License-Identfier: AGPL3.0-or-later
19 # Aggregate benchmarking data from multiple threads/processes
20 # generated by util/benchmark.c.
23 # awk -f collect.awk gnunet-benchmark-{ops,urls}-*.txt
26 # records are of the following forms:
27 # 1:op 2:<op> 3:count 4:<count> 6:time_us 7:<time_us>
28 # 1:url 2:<url> 3:status 4:<status> 5:count 6:<count> 7:time_us 8:<time_us> 9:time_us_max 10:<time_us_max>
29 # 11:bytes_sent 12:<bytes_sent> 13:bytes_received 14:<bytes_received>
41 op[$2]["time_us"] += t;
43 op[$2]["time_us_sq"] += n * (t/n) * (t/n);
46 } else if ($1 == "url") {
51 url[$2][$4]["count"] += n;
52 url[$2][$4]["time_us"] += t;
54 url[$2][$4]["time_us_sq"] += n * (t/n) * (t/n);
56 url[$2][$4]["bytes_sent"] += sent;
57 url[$2][$4]["bytes_received"] += recv;
58 max = url[$2][$4]["time_us_max"];
59 url[$2][$4]["time_us_max"] = (t/n > max ? t/n : max)
60 } else if ($1 == "op_baseline") {
61 # take average time for operations from baseline values with format:
62 # op_baseline <opname> time_avg_us <t>
68 function avg(sum, n) {
76 function stdev(sum, sum_sq, n) {
80 return sqrt(abs((sum_sq / n) - ((sum / n) * (sum / n))));
86 print "op", x, "count", op[x]["count"], "time_us", op[x]["time_us"], \
87 "time_avg_us", avg(op[x]["time_us"], op[x]["count"]), \
88 "stdev", stdev(op[x]["time_us"], op[x]["time_us_sq"], op[x]["count"]);
92 print "url", x, "status", y, \
93 "count", url[x][y]["count"], "time_us", url[x][y]["time_us"], \
94 "time_avg_us", avg(url[x][y]["time_us"], url[x][y]["count"]), \
95 "stdev", stdev(url[x][y]["time_us"], url[x][y]["time_us_sq"], url[x][y]["count"]), \
96 "time_us_max", url[x][y]["time_us_max"], \
97 "bytes_sent_avg", avg(url[x][y]["bytes_sent"], url[x][y]["count"]), \
98 "bytes_received_avg", avg(url[x][y]["bytes_received"], url[x][y]["count"]);
102 print "total_ops_ms", total_ops;
105 # Invoke awk with -V baseline_out=<filename> to extract baseline average
108 print "op_baseline", x, "time_avg_us", avg(op[x]["time_us"], op[x]["count"]) > baseline_out
114 total_ops_adjusted += op_baseline[x] * op[x]["count"];
116 print "total_ops_adjusted_ms", int(total_ops_adjusted);