From 2c6b3f5b81315da5e215848515e0069af321d1b2 Mon Sep 17 00:00:00 2001 From: "dslomov@chromium.org" Date: Fri, 17 Oct 2014 09:26:55 +0000 Subject: [PATCH] Initial set of perf tests for classes. R=arv@chromium.org, machenbach@chromium.org, rossberg@chromium.org Review URL: https://codereview.chromium.org/645933003 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24684 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- test/js-perf-test/Classes/Classes.json | 12 +++++++ test/js-perf-test/Classes/run.js | 27 ++++++++++++++++ test/js-perf-test/Classes/super.js | 59 ++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 test/js-perf-test/Classes/Classes.json create mode 100644 test/js-perf-test/Classes/run.js create mode 100644 test/js-perf-test/Classes/super.js diff --git a/test/js-perf-test/Classes/Classes.json b/test/js-perf-test/Classes/Classes.json new file mode 100644 index 0000000..a24dba9 --- /dev/null +++ b/test/js-perf-test/Classes/Classes.json @@ -0,0 +1,12 @@ +{ + "path": ["."], + "main": "run.js", + "flags": ["--harmony-classes"], + "run_count": 5, + "units": "score", + "results_regexp": "^%s\\-Classes\\(Score\\): (.+)$", + "total": true, + "tests": [ + {"name": "Super"} + ] +} diff --git a/test/js-perf-test/Classes/run.js b/test/js-perf-test/Classes/run.js new file mode 100644 index 0000000..bb3921f --- /dev/null +++ b/test/js-perf-test/Classes/run.js @@ -0,0 +1,27 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +load('../base.js'); +load('super.js'); + + +var success = true; + +function PrintResult(name, result) { + print(name + '-Classes(Score): ' + result); +} + + +function PrintError(name, error) { + PrintResult(name, error); + success = false; +} + + +BenchmarkSuite.config.doWarmup = undefined; +BenchmarkSuite.config.doDeterministic = undefined; + +BenchmarkSuite.RunSuites({ NotifyResult: PrintResult, + NotifyError: PrintError }); diff --git a/test/js-perf-test/Classes/super.js b/test/js-perf-test/Classes/super.js new file mode 100644 index 0000000..a9ec766 --- /dev/null +++ b/test/js-perf-test/Classes/super.js @@ -0,0 +1,59 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +'use strict'; + +var SuperBenchmark = new BenchmarkSuite('Super', [100], [ + new Benchmark('SuperMethodCall', false, false, 0, SuperMethodCall), + new Benchmark('SuperGetterCall', false, false, 0, SuperGetterCall), + new Benchmark('SuperSetterCall', false, false, 0, SuperSetterCall), +]); + + +function Base() { } +Base.prototype = { + constructor: Base, + get x() { + return this._x++; + }, + set x(v) { + this._x += v; + return this._x; + } +} + +Base.prototype.f = function() { + return this._x++; +}.toMethod(Base.prototype); + +function Derived() { + this._x = 1; +} +Derived.prototype = Object.create(Base.prototype); +Object.setPrototypeOf(Derived, Base); + +Derived.prototype.SuperCall = function() { + return super.f(); +}.toMethod(Derived.prototype); + +Derived.prototype.GetterCall = function() { + return super.x; +}.toMethod(Derived.prototype); + +Derived.prototype.SetterCall = function() { + return super.x = 5; +}.toMethod(Derived.prototype); + +var derived = new Derived(); + +function SuperMethodCall() { + return derived.SuperCall(); +} + +function SuperGetterCall() { + return derived.GetterCall(); +} + +function SuperSetterCall() { + return derived.SetterCall(); +} -- 2.7.4