@@ -334,42 +334,29 @@ jobs:
334334 if : runner.os == 'Linux'
335335 run : |
336336 sudo apt-get install -y -qq strace >/dev/null
337+ COUNT='import json,collections,sys; t=collections.Counter(json.loads(l)["type"] for l in open(sys.argv[1]) if l.strip()); print(" ", dict(t))'
337338
338339 echo "##### 1. C toy in THIS job (control: is the environment sane?)"
339340 g++ -g -O2 -c benchmarks/toy/toy.cpp -Iinclude -o /tmp/t.o
340341 g++ -g /tmp/t.o -o /tmp/ctoy -ldl -lpthread
341342 timeout 150 ./coz run -o /tmp/c.jsonl --- /tmp/ctoy >/dev/null 2>&1 || true
342- python3 -c "
343- import json,collections
344- t=collections.Counter()
345- for l in open('/tmp/c.jsonl') :
346- l=l.strip()
347- if l : t[json.loads(l)['type']]+=1
348- print(' C toy record types:', dict(t))
349- " || echo " C toy: no profile"
343+ python3 -c "$COUNT" /tmp/c.jsonl || echo " C toy: no profile"
350344
351345 echo "##### 2. does perf_event_open succeed for the Rust toy?"
352- strace -f -qq -e trace=perf_event_open -o /tmp/st.txt ./coz run -o /tmp/s.jsonl --- ./rust/target/release/examples/toy >/dev/null 2>&1 || true
353- echo " perf_event_open calls : $(grep -c perf_event_open /tmp/st.txt || echo 0)"
354- echo " failures:"; grep perf_event_open /tmp/st.txt | grep -E '= -1' | head -3 | sed 's/^/ /' || echo " none"
355- grep perf_event_open /tmp/st.txt | head -2 | sed 's/^/ sample : /'
346+ strace -f -qq -e trace=perf_event_open -o /tmp/st.txt ./coz run -o /tmp/s.jsonl --- ./rust/target/release/examples/toy >/dev/null 2>&1 || true
347+ echo " perf_event_open calls: $(grep -c perf_event_open /tmp/st.txt || true)"
348+ echo " failing calls:"; grep perf_event_open /tmp/st.txt | grep -E '= -1' | head -3 | sed 's/^/ /' || true
349+ echo " first call:"; grep perf_event_open /tmp/st.txt | head -1 | sed 's/^/ /' || true
350+ python3 -c "$COUNT" /tmp/s.jsonl || echo " no profile"
356351
357- echo "##### 3. profiler lifecycle (verbose, no head/SIGPIPE )"
352+ echo "##### 3. profiler lifecycle (verbose, captured to a file )"
358353 timeout 120 ./coz run --verbose -o /tmp/v.jsonl --- ./rust/target/release/examples/toy >/tmp/v.txt 2>&1 || true
359- grep -aE 'Profiler thread|Registered thread|Starting sampling|startup complete' /tmp/v.txt | head -8 | sed 's/^/ /'
360- echo " verbose profile record types:"
361- python3 -c "
362- import json,collections
363- t=collections.Counter()
364- for l in open('/tmp/v.jsonl') :
365- l=l.strip()
366- if l : t[json.loads(l)['type']]+=1
367- print(' ', dict(t))
368- " || echo " none"
369-
370- echo "##### 4. same, but C toy under strace for comparison"
371- strace -f -qq -e trace=perf_event_open -o /tmp/st2.txt ./coz run -o /tmp/c2.jsonl --- /tmp/ctoy >/dev/null 2>&1 || true
372- echo " C toy perf_event_open calls : $(grep -c perf_event_open /tmp/st2.txt || echo 0)"
354+ grep -aE 'Profiler thread|Registered thread|Starting sampling|startup complete' /tmp/v.txt | head -8 | sed 's/^/ /' || true
355+ python3 -c "$COUNT" /tmp/v.jsonl || echo " no profile"
356+
357+ echo "##### 4. C toy under strace, for comparison"
358+ strace -f -qq -e trace=perf_event_open -o /tmp/st2.txt ./coz run -o /tmp/c2.jsonl --- /tmp/ctoy >/dev/null 2>&1 || true
359+ echo " C toy perf_event_open calls: $(grep -c perf_event_open /tmp/st2.txt || true)"
373360
374361 - name : Profile the Rust toy under coz
375362 run : |
0 commit comments