Home | History | Annotate | Download | only in native_Benchmarks
      1 # Copyright (c) 2015 The Chromium OS 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 from native_Benchmarks_common import *
      6 from v8 import v8
      7 
      8 class octane(object):
      9     """Build v8 and run octane with it on client"""
     10 
     11     def __init__(self, scratch_srv, scratch_cli, client, args):
     12         # Instantiating v8 builds the v8 engine.
     13         self.v8 = v8(scratch_srv, scratch_cli, client, args)
     14         self.client = client
     15         self.scratch_cli = scratch_cli
     16 
     17         # download octane to client
     18         src = '%s/octane.tar.bz2' % SERVER_TEST_ROOT
     19         dst = '%s/octane.tar.bz2' % scratch_cli
     20         rcp_check(client, src, dst,
     21                   'Error occurred while sending octane to client.\n')
     22 
     23         # unpack octane
     24         cmd = 'tar jxf %s -C %s' % (dst, scratch_cli)
     25         run_check(client, cmd, 'Error occurred while unpacking octane')
     26 
     27     def run(self):
     28         """Returns perf_value tuples"""
     29         # Octane needs to run in PATH_TO/octane.
     30         wd = '%s/octane' % self.scratch_cli
     31         cmd = 'cd %s && %s run_all.js' % (wd, self.v8.executable)
     32         log = run_check(self.client, cmd, "Error occurred while running v8")
     33         return self.parse(log)
     34 
     35     def parse(self, log):
     36         """Translate logs into perf_values tuples.
     37         @param log: the log to parse
     38         """
     39         pairs = [line.split(': ') for line in log.splitlines()]
     40         del pairs[-2]
     41         pairs[-1][0] = 'Total'
     42         return [{'description': 'Octane V2',
     43                  'graph': p[0],
     44                  'value': p[1],
     45                  'units': 'score'} for p in pairs]
     46