1 #!/usr/bin/env python 2 # Copyright 2015 The Chromium Authors. All rights reserved. 3 # Use of this source code is governed by a BSD-style license that can be 4 # found in the LICENSE file. 5 6 import json 7 import logging 8 import multiprocessing 9 import sys 10 import time 11 12 import buildbot 13 14 15 MASTER_NAME = 'chromium.perf' 16 BUILDER_NAMES = ('Win 7 Perf (1)', 'Mac 10.9 Perf (1)') 17 BENCHMARK_NAME = 'smoothness.top_25_smooth' 18 VALUE_NAME = 'frame_times' 19 20 BUILD_COUNT = 100 21 22 23 def QueryBuild(build): 24 steps = build.steps 25 if not BENCHMARK_NAME in steps: 26 return None 27 28 step = steps[BENCHMARK_NAME] 29 if step.result != buildbot.SUCCESS: 30 return None 31 32 revision_data = [] 33 trace_results = step.results['chart_data']['charts'][VALUE_NAME].iteritems() 34 for user_story_name, user_story_data in trace_results: 35 revision_data.append({ 36 'user_story': user_story_name, 37 'start_time': step.start_time, 38 'end_time': step.end_time, 39 'values': user_story_data['values'], 40 }) 41 return { 42 'start_time': build.start_time, 43 'end_time': build.end_time, 44 'user_story_runs': revision_data, 45 } 46 47 48 def QueryBuilds(builder): 49 return map(QueryBuild, builder.LastBuilds(BUILD_COUNT)) 50 51 52 def main(): 53 logging.getLogger().setLevel(logging.INFO) 54 55 builders = buildbot.Builders(MASTER_NAME) 56 process_pool = multiprocessing.Pool(8) 57 58 start_time = time.time() 59 data = process_pool.map(QueryBuilds, 60 (builders[name] for name in BUILDER_NAMES)) 61 data = dict(zip(BUILDER_NAMES, data)) 62 logging.info('Queried %d builds in %2.2f seconds.', 63 BUILD_COUNT, time.time() - start_time) 64 65 start_time = time.time() 66 json.dump(data, sys.stdout) 67 logging.info('Wrote data in %2.2f seconds.', time.time() - start_time) 68 69 70 if __name__ == '__main__': 71 main() 72