-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathgenerate_table.awk
executable file
·53 lines (45 loc) · 1.31 KB
/
generate_table.awk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/gawk -f
#
# Usage: generate_table.awk < ${board}.txt
#
# Takes the *.txt file generated by AutoBenchmark.ino and generates an ASCII
# table that can be inserted into the README.md. Collects both sizeof()
# information as well as CPU benchmarks.
BEGIN {
# Set to 1 when 'BENCHMARKS' is detected
collect_benchmarks = 0
}
/^BENCHMARKS/ {
collect_benchmarks = 1
benchmark_index = 0
next
}
!/^END/ {
if (collect_benchmarks) {
u[benchmark_index]["name"] = $1
u[benchmark_index]["micros"] = $2
u[benchmark_index]["count"] = $3
u[benchmark_index]["writeCount"] = $4
u[benchmark_index]["readCount"] = $5
benchmark_index++
}
}
END {
TOTAL_BENCHMARKS = benchmark_index
# Calculate the diff from baseline
baseline = u[0]["micros"]
for (i = 0; i < TOTAL_BENCHMARKS; i++) {
u[i]["diff"] = u[i]["micros"] - baseline
}
print ""
print "CPU:"
printf("+---------------+--------+-------------+--------+\n");
printf("| Functionality | count | micros/iter | diff |\n");
printf("+---------------+--------+-------------+--------+\n");
for (i = 0; i < TOTAL_BENCHMARKS; i++) {
name = u[i]["name"]
printf("| %-13s | %6d | %11.3f | %6.3f |\n",
name, u[i]["count"], u[i]["micros"], u[i]["diff"])
}
printf("+---------------+--------+-------------+--------+\n");
}