Skip to content

Commit

Permalink
Add performance test for binding-expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
TimvdLippe committed Feb 25, 2018
1 parent 423074d commit 42f7d78
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
77 changes: 77 additions & 0 deletions test/perf/binding-expressions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="../../bower_components/perf-tester/perf.js"></script>
<script src="../../bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../../polymer.html">
</head>

<body>

<!-- <template>
{{compute(alaksjflkasjflkasjflkasjlfkajslkfjaslkfjaaaaaaaaaaaaaaaaaaaaaaaa)]}
</template>
--> <!-- {{compute(tricky, 'literal\,\'zot\'', this.has.long.log.lo)]} -->

<template>
<span>{{foo}}</span> <span>{{foo.bar}}</span> <span>{{foo.bar.zot}}</span>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<span>{{compute(tricky, 'literal\,\'zot\'')}}</span>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<span>{{compute(tricky, 'literal\,\'zot\'', this.has.a.bogus.ending.bracket)]}</span>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<div class$="{{compute(a, b, c,d,e,f,g,h,i)}}">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<span>{{bindings.and.stuff}}</span>
<div id="zot"><span>[[computeFn(a, 'b', c, "d", 999)]]</span> literal <span>{{a.b}}</span> literally</div>
<div id="zot"><span>[[computeFn(a, 'b', c, "d", 999)]]</span> literal <span>{{a.b}}</span> literally</div>
<div id="zot"><span>[[computeFn(a, 'b', c, "d", 999)]]</span> literal <span>{{a.b}}</span> literally</div>
<div id="zot"><span>[[computeFn(a, 'b', c, "d", 999)]]</span> literal <span>{{a.b}}</span> literally</div>
<div id="zot"><span>[[computeFn(a, 'b', c, "d", 999)]]</span> literal <span>{{a.b}}</span> literally</div>
<div id="zot"><span>[[computeFn(a, 'b', c, "d", 999)]]</span> literal <span>{{a.b}}</span> literally</div>
<div id="zot"><span>[[computeFn(a, 'b', c, "d", 999)]]</span> literal <span>{{a.b}}</span> literally</div>
</div>
</template>

<script>
var COUNT = 1000;
var templates = [];
var template = document.querySelector('template');
for (var i=0; i<COUNT; i++) {
templates[i] = template.cloneNode(true);
}
console.perf();
for (var i=0; i<COUNT; i++) {
const klass = Polymer({
is: 'test-el-' + i,
_template: templates[i]
});
new klass();
}
console.perfEnd();
</script>

</body>
</html>
27 changes: 27 additions & 0 deletions test/perf/perf-tests.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!doctype html>
<html lang="en">
<head>

<meta charset="utf-8">
<script src="../../bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../bower_components/perf-tester/perf-tester.js"></script>
<link rel="import" href="../../polymer.html">
<style>
summary {
font-family: sans-serif;
font-size: 1.5em;
}
</style>

</head>
<body>
<summary>Perf is go.</summary>
<perf-tester runs="25"></perf-tester>

<script>
document.querySelector('perf-tester').tests = [
'binding-expressions.html'
];
</script>

</body>

0 comments on commit 42f7d78

Please sign in to comment.