Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Measure during compile process
./configure --disable-ccache --with-gui=qt5 --with-incompatible-bdb CC="$PWD/../devtools/ gcc" CXX="$PWD/../devtools/ g++" CPP="$PWD/../devtools/ cpp"
# Write compile command and statistics for later processing
echo "$@" >> $MEASURE_OUTPUT
/usr/bin/time -a -o $MEASURE_OUTPUT "$@"
# Process measurements file into a csv
import re
#g++ -DHAVE_CONFIG_H -I. -I../src/config -I./obj -DBUILD_BITCOIN_INTERNAL -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g -O2 -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -Wstack-protector -fstack-protector-all -MT crypto/libbitcoinconsensus_la-hmac_sha512.lo -MD -MP -MF crypto/.deps/libbitcoinconsensus_la-hmac_sha512.Tpo -c crypto/hmac_sha512.cpp -fPIC -DPIC -o crypto/.libs/libbitcoinconsensus_la-hmac_sha512.o
#0.06user 0.01system 0:00.07elapsed 98%CPU (0avgtext+0avgdata 13876maxresident)k
#0inputs+96outputs (0major+5806minor)pagefaults 0swaps
re_source = re.compile('[^ ]+\.(cpp|cc)')
re_stats1 = re.compile('([0-9\.]+)user ([0-9\.]+)system ([0-9\.:]+)elapsed ([0-9]+)%CPU \(([0-9]+)avgtext\+([0-9]+)avgdata ([0-9]+)maxresident\)k')
re_stats2 = re.compile('([0-9]+)inputs\+([0-9]+)outputs \(([0-9]+)major\+([0-9]+)minor\)pagefaults ([0-9]+)swaps')
def read_stats(filename):
out = []
with open(filename) as f:
state = 0
for line in f:
line = line.rstrip()
if state == 0:
cmd = line
state = 1
elif state == 1:
if line.startswith("Command exited with non-zero status"):
continue # hack around leveldb detection
state = 2
m = re_stats1.match(line)
if not m:
print('could not parse line1: '+line)
line1 = m.groups()
elif state == 2:
state = 0
m = re_stats2.match(line)
if not m:
print('could not parse line2: '+line)
line2 = m.groups()
# Extract name
m =
ispic = '-fPIC' in cmd
if m:
name =
out.append((name,ispic) + line1 + line2)
pass # no source file (linking stage etc...)
return out
out = read_stats(MEASURE_OUTPUT)
import csv
with open(CSV_OUTPUT,'w') as f:
w = csv.writer(f)
#re_stats1 = re.compile('([0-9\.]+)user ([0-9\.]+)system ([0-9\.:]+)elapsed ([0-9]+)%CPU \(([0-9]+)avgtext\+([0-9]+)avgdata ([0-9]+)maxresident\)k')
#re_stats2 = re.compile('([0-9]+)inputs\+([0-9]+)outputs \(([0-9]+)major\+([0-9]+)minor\)pagefaults ([0-9]+)swaps')
for line in out:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.