Comments (1)
I've looked into it over the week, and I have a problem on how to approach it.
- On the one hand, we'd like to measure the performance change in a real-life scenario. That involves a complete data change -> render -> DOM change cycle. However, the non-DOM operations take so little computation here, that it's barely visible in the profiler.
- On the other, we could focus on the underneath helpers, like
Spacebars.dot
. However, as written above, in a real-life scenario, these account for 1-3% of CPU.
I did prepare a basic example that rerenders a lot of times on click.
Templates
<head>
<title>blaze-benchmarks</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
{{> benchmark template='let_alias' iterations=1000}}
{{> benchmark template='let_object_shallow' iterations=1000}}
{{> benchmark template='let_object_deep' iterations=1000}}
</body>
<template name="benchmark">
<button>Run</button>
<code style="display: inline-block; width: 20ch"><b>{{template}}</b></code>
{{#if summary}}
<code>{{summary}}</code>
{{/if}}
<br>
<div style="display: none">
{{> Template.dynamic data=data template=template}}
</div>
</template>
<template name="let_alias">
{{#let x=a}}{{x}}{{/let}}
</template>
<template name="let_object_shallow">
{{#let x=a.b}}{{x}}{{/let}}
</template>
<template name="let_object_deep">
{{#let x=a.b.c.d.e.f}}{{x}}{{/let}}
</template>
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import './main.html';
const values = new ReactiveVar({
a: { b: { c: { d: { e: { f: '' } } } } }
});
Template.benchmark.onCreated(function () {
this.summary = new ReactiveVar(null);
});
Template.benchmark.events({
'click button'(event, { data: { iterations }, summary }) {
const timings = [];
// Warmup.
for (let iteration = 0; iteration < iterations; ++iteration) {
values.dep.changed();
Tracker.flush();
}
// Measurement.
for (let round = 0; round < 100; ++round) {
const now = performance.now();
for (let iteration = 0; iteration < iterations; ++iteration) {
values.dep.changed();
Tracker.flush();
}
timings.push(performance.now() - now);
}
// Summary.
const ps = [25, 50, 90, 95];
timings.sort();
summary.set(ps.map(p => `p${p}=${Math.floor(timings[p - 1])}`).join(' '));
},
});
Template.benchmark.helpers({
data: () => values.get(),
summary: () => Template.instance().summary.get(),
});
But, as expected, these all take basically the same amount of time.
What do others think about it?
from blaze.
Related Issues (20)
- Move codebase to ES6 HOT 15
- spacebars-tests packages still uses removed code
- Blaze.remove() destroys DOM before calling onDestroyed() HOT 8
- Error handling, callbacks and DOMRange HOT 9
- Errors in onCreated callback cause a complete stop for rendering further Templates
- Bootstrap select picker is not correctly removed / disposed during Template descruction HOT 6
- Add benchmarks to tests
- SSR is broken in 2.6.0 HOT 4
- Add ts types HOT 3
- Be able to have more contentBlock in template HOT 1
- Non-primitives not fully reactive in 2.7
- Complete GitHub community standards HOT 7
- CI/CD for documentaiton
- observe-sequence has a bug when _ids have a period HOT 11
- Possibility of a release for people wanting to update to be able to migrate their templates to ASYNC? HOT 4
- Support for async dynamic attributes HOT 3
- TypeError: `Cannot convert undefined or null to object` in `waitForAllAttributesAndContinue` HOT 3
- Allowing arbitrary expressions
- Async Helpers are not reactive after the first "await" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blaze.