interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / tools / argus / r8_perthread.awk

29 lines · 1441 bytes Raw Blame History
1# Parses `perf report -T --stdio` per-thread counters into one JSON line.
2# Classes: consumer (tid == root+1 when cfg != 0: the RX_ARGUS=2
3# constructor creates it before main), workers (other threads of root), children
4# (other processes: R8's posix_spawn'd /bin/true). root = smallest pid in the table.
5# main (the leader thread) is not in perf report -T; it comes in as mainj from a
6# separate `perf stat --no-inherit` run of the same cfg in the same round.
7/^#[ ]+PID[ ]+TID/ { for (i = 2; i <= NF; i++) h[i-1] = $i; hdr = 1; next }
8hdr && NF >= 10 && $1 ~ /^[0-9]+$/ { rows[++nr] = $0; if (root == "" || $1 + 0 < root) root = $1 + 0; next }
9END {
10 for (q = 1; q <= nr; q++) {
11 nf = split(rows[q], f, " "); pid = f[1] + 0; tid = f[2] + 0
12 c = (pid != root) ? "children" : (tid == root) ? "main" : (tid == root + 1 && cfg != "0") ? "consumer" : "workers"
13 for (i = 3; i <= nf; i++) v[c SUBSEP i] += f[i]
14 n[c]++
15 }
16 printf "{\"cfg\":\"%s\",\"round\":%d,\"wall_us\":%d,\"passed\":%s", cfg, r, wall, pass
17 if (mainj != "") printf ",\"main\":%s", mainj
18 split("consumer workers children", cl, " ")
19 for (j = 1; j <= 3; j++) {
20 c = cl[j]; printf ",\"%s\":{\"n\":%d", c, n[c] + 0
21 for (i = 3; i in h; i++) {
22 k = h[i]; if (k ~ /dummy|period/) continue
23 gsub(/armv8_pmuv3_/, "pmu", k); gsub(/\//, "_", k); sub(/_$/, "", k)
24 printf ",\"%s\":%d", k, v[c SUBSEP i] + 0
25 }
26 printf "}"
27 }
28 print "}"
29}