Skip to content

Commit

Permalink
Merge pull request #4696 from runspired/bench/query-materialization
Browse files Browse the repository at this point in the history
fix(benchmarks): benchmarks for store.query no longer included record…
  • Loading branch information
bmac authored Dec 7, 2016
2 parents d3e7546 + 7bf3805 commit 701eff4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions addon/-private/system/model/internal-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ export default class InternalModel {
getRecord() {
if (!this._record) {
heimdall.increment(materializeRecord);
let token = heimdall.start('InternalModel.getRecord');

// lookupFactory should really return an object that creates
// instances with the injections applied
Expand All @@ -285,6 +286,7 @@ export default class InternalModel {
this._record = this.modelClass._create(createOptions);

this._triggerDeferredTriggers();
heimdall.stop(token);
}

return this._record;
Expand Down
5 changes: 5 additions & 0 deletions tests/dummy/app/routes/query/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export default Route.extend({
let token = heimdall.start('ember-data');
return this.get('store').query(modelName, params)
.then((records) => {
// RecordArray lazily materializes the records
// We call toArray() to force materialization for benchmarking
// otherwise we would need to consume the RecordArray in our UI
// and clutter our benchmarks and make it harder to time.
records.toArray();
heimdall.stop(token);
window.result = heimdall.toString();

Expand Down

0 comments on commit 701eff4

Please sign in to comment.