diff options
author | Robin Burchell <robin.burchell@crimson.no> | 2017-05-04 21:16:38 +0200 |
---|---|---|
committer | Robin Burchell <robin.burchell@crimson.no> | 2017-05-06 15:50:30 +0000 |
commit | 52b11df60ba013643e768bab4c442cb2c2e5b030 (patch) | |
tree | 26403e99e692e3838e3d9f1bdc1982c177ac8806 | |
parent | 573723ef55970bfa036c84902faf9e20501d5411 (diff) |
Add a V8Benchmark type to QmlBench import
This is going to be used to run v8-bench benchmarks using qmlbench as a harness.
This reverts commit 156cdf3b2ec213843f13240c160bcb25144a12c2.
Change-Id: Ieae04fd9fd968ac7bc419767afbf235b67242779
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r-- | src/V8Benchmark.qml | 90 | ||||
-rw-r--r-- | src/main.cpp | 1 | ||||
-rw-r--r-- | src/qmlbench.qrc | 2 |
3 files changed, 93 insertions, 0 deletions
diff --git a/src/V8Benchmark.qml b/src/V8Benchmark.qml new file mode 100644 index 0000000..6062153 --- /dev/null +++ b/src/V8Benchmark.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Crimson AS <info@crimson.no> +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the qmlbench tool. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlBench 1.0 +import "qrc:/3rdparty/v8-bench.js" as V8Bench + +// This is a harness suited for running a V8Bench suite and reporting a number. +// We replace most of V8Bench's BenchmarkSuite (specifically, the step, run, etc +// behavior) and do our own setup, running and teardown. +// +// This is a little unfortunate as it means that we can't report results that +// directly compare with v8-bench.js, but hopefully our results will be more +// stable (as we have less magic in how many iterations we run), and we shall +// still provide useful information if a test regresses. +Benchmark { + id: root + + // The desired suite name (e.g. "Richards"). This is then found, and put + // into suite. + property var suiteName + + // The found suite object + property var suite + + Component.onCompleted: { + var suites = V8Bench.BenchmarkSuite.suites + // Find suite + for (var i = 0; i < suites.length; ++i) { + var potentialSuite = suites[i] + if (potentialSuite.name == root.suiteName) { + root.suite = potentialSuite + break; + } + } + + // Set it up + for (var i = 0; i < suite.benchmarks.length; ++i) { + var benchmark = suite.benchmarks[i] + benchmark.Setup(); + + // And do a warmup iteration + benchmark.run(); + } + } + Component.onDestruction: { + // Tear it down + for (var i = 0; i < suite.benchmarks.length; ++i) { + var benchmark = suite.benchmarks[i] + benchmark.TearDown(); + } + } + + // Run a tick of the test + onTChanged: { + for (var i = 0; i < suite.benchmarks.length; ++i) { + var benchmark = suite.benchmarks[i] + + // Do a few iterations, so we report a meaningful number. + for (var j = 0; j < count; ++j) { + benchmark.run(); + } + } + } +} diff --git a/src/main.cpp b/src/main.cpp index 4133345..685c5a1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -365,6 +365,7 @@ int main(int argc, char **argv) qmlRegisterType<QQuickView>(); qmlRegisterType(QUrl("qrc:/Benchmark.qml"), "QmlBench", 1, 0, "Benchmark"); qmlRegisterType(QUrl("qrc:/CreationBenchmark.qml"), "QmlBench", 1, 0, "CreationBenchmark"); + qmlRegisterType(QUrl("qrc:/V8Benchmark.qml"), "QmlBench", 1, 0, "V8Benchmark"); qmlRegisterType<TestModel>("QmlBench", 1, 0, "TestModel"); QScopedPointer<QCoreApplication> app; diff --git a/src/qmlbench.qrc b/src/qmlbench.qrc index 63be422..b5e1ede 100644 --- a/src/qmlbench.qrc +++ b/src/qmlbench.qrc @@ -6,5 +6,7 @@ <file>Shell_TotalFramesWithStaticCount.qml</file> <file>Benchmark.qml</file> <file>CreationBenchmark.qml</file> + <file>V8Benchmark.qml</file> + <file>3rdparty/v8-bench.js</file> </qresource> </RCC> |