2018-07-04 15:39:44 +01:00
|
|
|
# Copyright 2014-2018 ARM Limited
|
2018-02-27 10:55:13 +00:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
|
2020-03-30 10:24:58 +01:00
|
|
|
from wa import ApkUiautoWorkload, Parameter
|
2018-07-03 13:39:53 +01:00
|
|
|
from wa.framework.exception import ValidationError, WorkloadError
|
2018-02-27 10:55:13 +00:00
|
|
|
from wa.utils.types import list_of_strs
|
|
|
|
from wa.utils.misc import unique
|
|
|
|
|
2020-04-02 17:33:48 +01:00
|
|
|
|
2020-03-30 10:24:58 +01:00
|
|
|
class Speedometer(ApkUiautoWorkload):
|
2018-02-27 10:55:13 +00:00
|
|
|
|
|
|
|
name = 'speedometer'
|
2020-03-30 10:24:58 +01:00
|
|
|
package_names = ['com.android.chrome']
|
2018-07-03 13:23:16 +01:00
|
|
|
regex = re.compile(r'Speedometer Score ([\d.]+)')
|
2018-03-19 10:53:16 +00:00
|
|
|
versions = ['1.0', '2.0']
|
2018-02-27 10:55:13 +00:00
|
|
|
description = '''
|
|
|
|
A workload to execute the speedometer web based benchmark
|
|
|
|
|
|
|
|
Test description:
|
2020-03-30 10:24:58 +01:00
|
|
|
1. Open chrome
|
2018-02-27 10:55:13 +00:00
|
|
|
2. Navigate to the speedometer website - http://browserbench.org/Speedometer/
|
|
|
|
3. Execute the benchmark
|
|
|
|
|
2020-03-30 10:24:58 +01:00
|
|
|
known working chrome version 80.0.3987.149
|
2018-02-27 10:55:13 +00:00
|
|
|
'''
|
|
|
|
|
2018-03-19 10:53:16 +00:00
|
|
|
parameters = [
|
2020-03-30 10:24:58 +01:00
|
|
|
Parameter('speedometer_version', allowed_values=versions, kind=str, default='2.0',
|
2018-03-19 10:53:16 +00:00
|
|
|
description='''
|
|
|
|
The speedometer version to be used.
|
|
|
|
''')
|
|
|
|
]
|
|
|
|
|
2019-07-05 16:09:28 +01:00
|
|
|
requires_network = True
|
|
|
|
|
2018-02-27 10:55:13 +00:00
|
|
|
def __init__(self, target, **kwargs):
|
|
|
|
super(Speedometer, self).__init__(target, **kwargs)
|
|
|
|
self.gui.timeout = 1500
|
2020-03-30 10:24:58 +01:00
|
|
|
self.gui.uiauto_params['version'] = self.speedometer_version
|
2018-02-27 10:55:13 +00:00
|
|
|
|
|
|
|
def update_output(self, context):
|
|
|
|
super(Speedometer, self).update_output(context)
|
|
|
|
result = None
|
|
|
|
logcat_file = context.get_artifact_path('logcat')
|
2020-04-02 17:33:48 +01:00
|
|
|
with open(logcat_file, errors='replace') as fh:
|
2018-02-27 10:55:13 +00:00
|
|
|
for line in fh:
|
|
|
|
match = self.regex.search(line)
|
|
|
|
if match:
|
|
|
|
result = float(match.group(1))
|
|
|
|
|
|
|
|
if result is not None:
|
|
|
|
context.add_metric('Speedometer Score', result, 'Runs per minute', lower_is_better=False)
|
|
|
|
else:
|
|
|
|
raise WorkloadError("The Speedometer workload has failed. No score was obtainable.")
|