Last active
April 12, 2016 19:41
-
-
Save jdanyow/0cf94292ad72cec25a724d646b85cafc to your computer and use it in GitHub Desktop.
Aurelia Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class App { | |
measurements = window.measurements; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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