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