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 Aug 3, 2017
1 parent 6aa37e4 commit 9cca465
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
},
"devDependencies": {
"web-component-tester": "^v6.0.0",
"test-fixture": "PolymerElements/test-fixture#3.0.0-rc.1"
"test-fixture": "PolymerElements/test-fixture#3.0.0-rc.1",
"perf-tester": "polymerlabs/perf-tester"
},
"private": true,
"resolutions": {
Expand Down
76 changes: 76 additions & 0 deletions test/perf/binding-expressions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!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++) {
Polymer({
is: 'test-el-' + i,
_template: templates[i]
});
}
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="50"></perf-tester>

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

</body>

0 comments on commit 9cca465

Please sign in to comment.