Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1465336 - add six-speed to jsshell-bench framework. r=ahal
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaher committed May 30, 2018
1 parent 1e8cb84 commit 444ba44
Show file tree
Hide file tree
Showing 56 changed files with 878 additions and 0 deletions.
12 changes: 12 additions & 0 deletions taskcluster/ci/source-test/jsshell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,15 @@ bench-ares6:
export JSSHELL=$USE_ARTIFACT_PATH/build/jsshell/js &&
cd /builds/worker/checkouts/gecko &&
./mach jsshell-bench --binary $JSSHELL --perfherder ares6
bench-sixspeed:
description: Six-Speed JavaScript shell benchmark suite
treeherder:
symbol: js-bench(6speed)
run:
command: >
cd $USE_ARTIFACT_PATH/build &&
unzip -q -d jsshell target.jsshell.zip &&
export JSSHELL=$USE_ARTIFACT_PATH/build/jsshell/js &&
cd /builds/worker/checkouts/gecko &&
./mach jsshell-bench --binary $JSSHELL --perfherder six-speed
42 changes: 42 additions & 0 deletions testing/jsshell/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def reset(self):
'shouldAlert': self.should_alert,
'subtests': [],
'units': self.units,
'value': None
},
],
}
Expand Down Expand Up @@ -158,8 +159,49 @@ def collect_results(self):
self.suite['value'] = self.last_summary


class SixSpeed(Benchmark):
name = 'six-speed'
path = os.path.join('third_party', 'webkit', 'PerformanceTests', 'six-speed')
units = 'ms'

@property
def command(self):
cmd = super(SixSpeed, self).command
return cmd + ['test.js']

def reset(self):
super(SixSpeed, self).reset()

# Scores are of the form:
# {<bench_name>: {<score_name>: [<values>]}}
self.scores = defaultdict(lambda: defaultdict(list))

def process_line(self, output):
m = re.search("(.+): (\d+)", output)
if not m:
return
subtest = m.group(1)
score = m.group(2)
if subtest not in self.scores[self.name]:
self.scores[self.name][subtest] = []
self.scores[self.name][subtest].append(int(score))


def collect_results(self):
bench_total = 0
# NOTE: for this benchmark we run the test once, so we have a single value array
for bench, scores in self.scores.items():
for score, values in scores.items():
test_name = "{}-{}".format(self.name, score)
total = sum(values) / len(values)
self.suite['subtests'].append({'name': test_name, 'value': total})
bench_total += int(sum(values))
self.suite['value'] = bench_total


all_benchmarks = {
'ares6': Ares6,
'six-speed': SixSpeed,
}


Expand Down
1 change: 1 addition & 0 deletions third_party/webkit/PerformanceTests/six-speed/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1
85 changes: 85 additions & 0 deletions third_party/webkit/PerformanceTests/six-speed/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

function assertEqual() {}
function test(fn) {
var its = iterations;
var start = Date.now();
for (var i = 0; i < its; i++) {
fn();
}
timing = Date.now() - start;
}

var tests = [
"template_string",
"defaults",
"map-set-lookup",
"spread",
"object-assign",
"spread-literal",
"map-set",
"destructuring-simple",
"super",
"for-of-object",
"rest",
"regex-u",
"arrow",
"bindings-compound",
"classes",
"template_string_tag",
"map-string",
"arrow-declare",
"spread-generator",
"object-literal-ext",
"generator",
"arrow-args",
"for-of-array",
"bindings",
"destructuring",
"map-set-object"
]
var iteration_for_test = [
200000000,
100000000,
200000,
1000000,
600000,
1000000,
10000,
20000000,
3000000,
1000000,
500000,
1000000,
20000000,
20000000,
10000000,
2000000,
30000000,
30000000,
1000000,
1000000,
3000000,
20000000,
5000000,
20000000,
20000000,
5000
]

for (var z = 0; z < tests.length; z++) {
var timing = 0;
var testname = tests[z];
var iterations = iteration_for_test[z];

// ES5
var content = read("tests/"+testname+".es5")
var func = new Function(content);
func();
print(testname+"-es5:", timing);

// ES6
var content = read("tests/"+testname+".es6")
var func = new Function(content);
func();
print(testname+"-es6:", timing);
}
16 changes: 16 additions & 0 deletions third_party/webkit/PerformanceTests/six-speed/tests/arrow-args.es5
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var obj = {
value: 42,
fn: function() {
var args = arguments;
return function() {
return args[0];
};
}
};

var fn = obj.fn(1);
assertEqual(fn(), 1);

test(function() {
fn();
});
14 changes: 14 additions & 0 deletions third_party/webkit/PerformanceTests/six-speed/tests/arrow-args.es6
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

var obj = {
value: 42,
fn: function() {
return () => arguments[0];
}
};

var fn = obj.fn(1);
assertEqual(fn(), 1);

test(function() {
fn();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var obj = {
value: 42,
fn: function() {
return function() {
return obj.value;
};
}
};

assertEqual(obj.fn()(), 42);

test(function() {
obj.fn();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

var obj = {
value: 42,
fn: function() {
return () => this.value;
}
};

assertEqual(obj.fn()(), 42);

test(function() {
obj.fn();
});
15 changes: 15 additions & 0 deletions third_party/webkit/PerformanceTests/six-speed/tests/arrow.es5
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var obj = {
value: 42,
fn: function() {
return function() {
return obj.value;
};
}
};

var fn = obj.fn();
assertEqual(fn(), 42);

test(function() {
fn();
});
14 changes: 14 additions & 0 deletions third_party/webkit/PerformanceTests/six-speed/tests/arrow.es6
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

var obj = {
value: 42,
fn: function() {
return () => this.value;
}
};

var fn = obj.fn();
assertEqual(fn(), 42);

test(function() {
fn();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var b = 2;

assertEqual(fn(), 3);

function fn() {
var a = 1;
a += b;

return a;
}
test(fn);
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use strict";

const b = 2;

function fn() {

let a = 1;
a += b;

return a;
}

assertEqual(fn(), 3);
test(fn);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var a = 1,
b = 2;

assertEqual(a+b, 3);

test(function() {
return a + b;
});
10 changes: 10 additions & 0 deletions third_party/webkit/PerformanceTests/six-speed/tests/bindings.es6
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"use strict";

const a = 1;
let b = 2;

assertEqual(a+b, 3);

test(function() {
return a + b;
});
11 changes: 11 additions & 0 deletions third_party/webkit/PerformanceTests/six-speed/tests/classes.es5
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function C() {
this.foo = 'bar';
}
C.prototype.bar = function() {
};

assertEqual(new C().foo, 'bar');

test(function() {
return new C();
});
13 changes: 13 additions & 0 deletions third_party/webkit/PerformanceTests/six-speed/tests/classes.es6
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class C {
constructor() {
this.foo = 'bar';
}
bar() {
}
}

assertEqual(new C().foo, 'bar');

test(function() {
return new C();
});
14 changes: 14 additions & 0 deletions third_party/webkit/PerformanceTests/six-speed/tests/defaults.es5
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function fn(arg, other) {
arg = arg === undefined ? 1 : arg;
other = other === undefined ? 3 : other;
return other;
}

assertEqual(fn(), 3);
assertEqual(fn(1, 2), 2);

test(function() {
fn();
fn(2);
fn(2, 4);
});
13 changes: 13 additions & 0 deletions third_party/webkit/PerformanceTests/six-speed/tests/defaults.es6
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function fn(arg = 1, other = 3) {
return other;
}


assertEqual(fn(), 3);
assertEqual(fn(1, 2), 2);

test(function() {
fn();
fn(2);
fn(2, 4);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var data = {
a: 'foo',
b: {c: 'd'},
arr: [1, 2, 3]
};

function fn() {
var a = data.a,
b = data.b;
return a;
}

assertEqual(fn(), 'foo');
test(fn);
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var data = {
a: 'foo',
b: {c: 'd'},
arr: [1, 2, 3]
};

function fn() {
var {a, b} = data;
return a;
}

assertEqual(fn(), 'foo');

test(fn);
Loading

0 comments on commit 444ba44

Please sign in to comment.