Home | History | Annotate | Download | only in recipes
      1 # Copyright 2016 The Chromium Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 
      6 # Recipe for Skia skpbench.
      7 
      8 
      9 import calendar
     10 
     11 
     12 DEPS = [
     13   'core',
     14   'flavor',
     15   'recipe_engine/context',
     16   'recipe_engine/file',
     17   'recipe_engine/path',
     18   'recipe_engine/properties',
     19   'recipe_engine/python',
     20   'recipe_engine/raw_io',
     21   'recipe_engine/step',
     22   'recipe_engine/time',
     23   'run',
     24   'vars',
     25 ]
     26 
     27 
     28 def _run(api, title, *cmd, **kwargs):
     29   with api.context(cwd=api.vars.skia_dir):
     30     return api.run(api.step, title, cmd=list(cmd), **kwargs)
     31 
     32 
     33 def _adb(api, title, *cmd, **kwargs):
     34   if 'infra_step' not in kwargs:
     35     kwargs['infra_step'] = True
     36   return _run(api, title, 'adb', *cmd, **kwargs)
     37 
     38 
     39 def skpbench_steps(api):
     40   """benchmark Skia using skpbench."""
     41   app = api.vars.skia_out.join(api.vars.configuration, 'skpbench')
     42   _adb(api, 'push skpbench', 'push', app, api.vars.android_bin_dir)
     43 
     44   skpbench_dir = api.vars.slave_dir.join('skia', 'tools', 'skpbench')
     45   table = api.path.join(api.vars.swarming_out_dir, 'table')
     46 
     47   config = 'gles,glesinst4'
     48   if 'Vulkan' in api.vars.builder_name:
     49     config = 'vk'
     50 
     51   skpbench_args = [
     52         api.path.join(api.vars.android_bin_dir, 'skpbench'),
     53         api.path.join(api.vars.android_data_dir, 'skps'),
     54         '--adb',
     55         '--resultsfile', table,
     56         '--config', config,
     57         # TODO(dogben): Track down what's causing bots to die.
     58         '-v', '5']
     59 
     60   api.run(api.python, 'skpbench',
     61       script=skpbench_dir.join('skpbench.py'),
     62       args=skpbench_args)
     63 
     64   skiaperf_args = [
     65     table,
     66     '--properties',
     67     'gitHash',      api.vars.got_revision,
     68   ]
     69   if api.vars.is_trybot:
     70     skiaperf_args.extend([
     71       'issue',    api.vars.issue,
     72       'patchset', api.vars.patchset,
     73       'patch_storage', api.vars.patch_storage,
     74     ])
     75 
     76   skiaperf_args.extend(['swarming_bot_id', api.vars.swarming_bot_id])
     77   skiaperf_args.extend(['swarming_task_id', api.vars.swarming_task_id])
     78 
     79   now = api.time.utcnow()
     80   ts = int(calendar.timegm(now.utctimetuple()))
     81   api.file.ensure_directory('makedirs perf_dir', api.vars.perf_data_dir)
     82   json_path = api.path.join(
     83       api.vars.perf_data_dir,
     84       'skpbench_%s_%d.json' % (api.vars.got_revision, ts))
     85 
     86   skiaperf_args.extend([
     87     '--outfile', json_path
     88   ])
     89 
     90   keys_blacklist = ['configuration', 'role', 'is_trybot']
     91   skiaperf_args.append('--key')
     92   for k in sorted(api.vars.builder_cfg.keys()):
     93     if not k in keys_blacklist:
     94       skiaperf_args.extend([k, api.vars.builder_cfg[k]])
     95 
     96   api.run(api.python, 'Parse skpbench output into Perf json',
     97       script=skpbench_dir.join('skiaperf.py'),
     98       args=skiaperf_args)
     99 
    100 
    101 def RunSteps(api):
    102   api.core.setup()
    103   try:
    104     api.flavor.install(skps=True)
    105     skpbench_steps(api)
    106   finally:
    107     api.flavor.cleanup_steps()
    108   api.run.check_failure()
    109 
    110 
    111 TEST_BUILDERS = [
    112   'Perf-Android-Clang-PixelC-GPU-TegraX1-arm64-Release-Android_Skpbench',
    113   ('Perf-Android-Clang-PixelC-GPU-TegraX1-arm64-Release-'
    114    'Android_Vulkan_Skpbench'),
    115 ]
    116 
    117 
    118 def GenTests(api):
    119   for builder in TEST_BUILDERS:
    120     test = (
    121       api.test(builder) +
    122       api.properties(buildername=builder,
    123                      revision='abc123',
    124                      path_config='kitchen',
    125                      swarm_out_dir='[SWARM_OUT_DIR]') +
    126       api.path.exists(
    127           api.path['start_dir'].join('skia'),
    128           api.path['start_dir'].join('skia', 'infra', 'bots', 'assets',
    129                                      'skp', 'VERSION'),
    130       ) +
    131       api.step_data('get swarming bot id',
    132           stdout=api.raw_io.output('skia-bot-123')) +
    133       api.step_data('get swarming task id',
    134           stdout=api.raw_io.output('123456'))
    135     )
    136 
    137     yield test
    138 
    139   b = 'Perf-Android-Clang-PixelC-GPU-TegraX1-arm64-Release-Android_Skpbench'
    140   yield (
    141     api.test('trybot') +
    142     api.properties(buildername=b,
    143                    revision='abc123',
    144                    path_config='kitchen',
    145                    swarm_out_dir='[SWARM_OUT_DIR]') +
    146     api.path.exists(
    147         api.path['start_dir'].join('skia'),
    148         api.path['start_dir'].join('skia', 'infra', 'bots', 'assets',
    149                                    'skp', 'VERSION'),
    150     ) +
    151     api.step_data('get swarming bot id',
    152         stdout=api.raw_io.output('skia-bot-123')) +
    153     api.step_data('get swarming task id',
    154         stdout=api.raw_io.output('123456')) +
    155     api.properties(patch_storage='gerrit') +
    156     api.properties.tryserver(
    157         buildername=b,
    158         gerrit_project='skia',
    159         gerrit_url='https://skia-review.googlesource.com/',
    160     )
    161   )
    162