mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-19 20:34:30 +00:00
63 lines
2.2 KiB
Python
63 lines
2.2 KiB
Python
# Copyright 2013-2015 ARM Limited
|
|
#
|
|
# 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 re
|
|
|
|
from wa import ApkUiautoWorkload
|
|
|
|
|
|
class BenchmarkPi(ApkUiautoWorkload):
|
|
|
|
name = 'benchmarkpi'
|
|
description = """
|
|
Measures the time the target device takes to run and complete the Pi
|
|
calculation algorithm.
|
|
|
|
http://androidbenchmark.com/howitworks.php
|
|
|
|
from the website:
|
|
|
|
The whole idea behind this application is to use the same Pi calculation
|
|
algorithm on every Android Device and check how fast that proccess is.
|
|
Better calculation times, conclude to faster Android devices. This way you
|
|
can also check how lightweight your custom made Android build is. Or not.
|
|
|
|
As Pi is an irrational number, Benchmark Pi does not calculate the actual Pi
|
|
number, but an approximation near the first digits of Pi over the same
|
|
calculation circles the algorithms needs.
|
|
|
|
So, the number you are getting in miliseconds is the time your mobile device
|
|
takes to run and complete the Pi calculation algorithm resulting in a
|
|
approximation of the first Pi digits.
|
|
"""
|
|
package_names = ['gr.androiddev.BenchmarkPi']
|
|
activity = '.BenchmarkPi'
|
|
|
|
regex = re.compile('You calculated Pi in ([0-9]+)')
|
|
|
|
def update_output(self, context):
|
|
super(BenchmarkPi, self).update_output(context)
|
|
logcat_file = context.get_artifact_path('logcat')
|
|
with open(logcat_file) as fh:
|
|
for line in fh:
|
|
match = self.regex.search(line)
|
|
if match:
|
|
result = int(match.group(1))
|
|
|
|
if result is not None:
|
|
context.add_metric('pi calculation', result,
|
|
'milliseconds', lower_is_better=True)
|