Skip to content

Instantly share code, notes, and snippets.

@weoreference
Forked from jdanyow/app.html
Created April 12, 2016 19:41
Show Gist options
  • Save weoreference/f97bac2eae47f8c486dda460593311e7 to your computer and use it in GitHub Desktop.
Save weoreference/f97bac2eae47f8c486dda460593311e7 to your computer and use it in GitHub Desktop.
Aurelia Gist
<template>
<table class="table">
<thead>
<tr>
<th>Stage</th>
<th>Elapsed Time</th>
<th>Promise Count</th>
</tr>
</thead>
<tbody>
<tr repeat.for="m of measurements">
<th>${m.name}</th>
<td>${m.elapsed}</td>
<td>${m.promises}</td>
</tr>
</tbody>
</table>
</template>
export class App {
measurements = window.measurements;
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
</head>
<body aurelia-app="main">
<h1>Loading...</h1>
<script>
// replace standard promise with one that count's instances.
window.promiseCount = 0;
var StandardPromise = window.Promise;
function PromiseCounter(resolve, reject) {
window.promiseCount++;
return new StandardPromise(resolve, reject);
}
PromiseCounter.resolve = function(value) {
window.promiseCount++;
return StandardPromise.resolve(value);
}
PromiseCounter.reject = function(value) {
window.promiseCount++;
return StandardPromise.reject(value);
}
PromiseCounter.all = function(value) {
window.promiseCount++;
return StandardPromise.all(value);
}
window.Promise = PromiseCounter;
</script>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/dist/aurelia-bundle.js"></script>
<script>
// define the main module (eliminate http request)
System.set('main', System.newModule({
configure: function(aurelia) {
window.measurements.push({
name: 'begin main - configure(aurelia)',
elapsed: Math.round(performance.now() - window.startTime),
promises: window.promiseCount
});
aurelia.use
.standardConfiguration()
.developmentLogging();
aurelia.start()
.then(() => {
window.measurements.push({
name: 'after aurelia.start()',
elapsed: Math.round(performance.now() - window.startTime),
promises: window.promiseCount
});
})
.then(() => aurelia.setRoot());
}
}));
</script>
<script>
window.measurements = [];
window.startTime = performance.now();
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment