Skip to content

Commit

Permalink
test(performance): repeat test-case
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Nov 8, 2017
1 parent 741cebf commit 0a96ae4
Showing 1 changed file with 30 additions and 19 deletions.
49 changes: 30 additions & 19 deletions test/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,36 +66,47 @@ describe('performance', function() {

it('should parse FAST (proxy)', function() {

// given
var no = 200;
this.timeout(10000);

// when
repeat(test({ proxy: true }), 5);
console.log('PERF (proxy -> plain)');

var t = time(repeater(test({ proxy: true }), no));
repeat(function() {
// given
var no = 200;

var average = t / no;
// when
repeat(test({ proxy: true }), 5);

var t = time(repeater(test({ proxy: true }), no));

repeat(test(), 5);
var average = t / no;

var t1 = time(repeater(test(), no));
repeat(test(), 5);

var average1 = t1 / no;
var t1 = time(repeater(test(), no));

console.log('PERF (plain)');
console.log('avg', average1);
console.log('sum', t1);
var average1 = t1 / no;

console.log('PERF (proxy)');
console.log('avg', average);
console.log('sum', t);
var difference = Math.round((t/t1) * 100) - 100;

var difference = Math.round((t/t1) * 100) - 100;
console.table({
PLAIN: {
avg: average1,
sum: t1,
diff: ''
},
PROXY: {
avg: average,
sum: t,
diff: (difference > 0 ? '+' : '') + difference + '%'
}
});

console.log('difference %s%s%', difference > 0 ? '+' : '', difference);
console.log('diff: %s%s% ', (difference > 0 ? '+' : ''), difference);

// then
assert.ok(average < 12, average + ' < 5');
// then
assert.ok(average < 12, average + ' < 5');
}, 5);
});

});

0 comments on commit 0a96ae4

Please sign in to comment.