[users at bb.net] Gathering and displaying build time statistics on buildbot?

Dan Kegel dank at kegel.com
Tue Mar 15 17:22:46 UTC 2016


[this time to list]

For completeness, here's the tool I'm using now with that kludge.
It's good enough for today, though the sparkly dashboard in nine would be nicer.

#!/bin/sh
# See http://trac.buildbot.net/wiki/BuildbotJson
# Report statistics on build times for builders that match given strings
# Show avg and max latency and duration
set -e
set -x

if test "$1" = ""
then
    filter1=-
else
    filter1=$1
fi

if test "$2" = ""
then
    filter2=-
else
    filter2=$2
fi

cat > report-stats.py << _EOF_
stats=[]
for bname in b.builders.keys:
  if '$filter1' in bname and '$filter2' in bname:
    builds = b.builders[bname].builds
    okbuilds = [build for build in builds if build.duration]
    sum_n = sum(1 for build in okbuilds)
    if (sum_n > 0):
      sum_duration = sum(build.duration for build in okbuilds)
      max_duration = max(build.duration for build in okbuilds)
      sum_latency = 0
      max_latency = -1
      n_latency = 0
      for build in okbuilds:
          if build.latency != None:
              sum_latency += build.latency
              if build.latency > max_latency:
                  max_latency = build.latency
                  n_latency += 1
      stats.append([sum_n, sum_duration/sum_n, max_duration,
((sum_latency/n_latency) if n_latency > 0 else -1), max_latency,
bname])

# Sort four different ways, show worst for each
def report(stats, label):
  print "Sorted by %s" % label
  n = 0
  for stat in stats:
     (sum_n, avg_duration, max_duration, avg_latency, max_latency, bname) = stat
     print "%-42s: duration: %4d .. %4d, latency: %4d .. %4d" %
(bname, avg_duration, max_duration, avg_latency, max_latency)
     n += 1
     if (n > 5):
        break


print "\nPrinting worst 5 $filter1 $filter2 builders:"
report(sorted(stats, key=lambda stat: -stat[1]), "avg_duration")
report(sorted(stats, key=lambda stat: -stat[2]), "max_duration")
report(sorted(stats, key=lambda stat: -stat[3]), "avg_latency")
report(sorted(stats, key=lambda stat: -stat[4]), "max_latency")

_EOF_

bbjs() {
    # patched copy of buildbot_json.py to report latency
    buildbot-local/buildbot_json.py $1 buildhost.example.com
}

bbjs interactive < report-stats.py


More information about the users mailing list