-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a325c65
commit dd1b773
Showing
3 changed files
with
77 additions
and
20 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,29 @@ | ||
require('./runner')( | ||
{ | ||
distribution: [0, 1, 5], | ||
name: 'create', | ||
distribution: [0, 5, 20], | ||
name: 'pushPayload', | ||
suites: [ | ||
require('./create/create-object'), | ||
require('./create/create-record') | ||
require('./push-payload/push-payload') | ||
] | ||
} | ||
); | ||
|
||
require('./runner')( | ||
{ | ||
distribution: [0], | ||
name: 'buildRecord', | ||
suites: [ | ||
require('./build/build-record') | ||
] | ||
} | ||
); | ||
|
||
require('./runner')( | ||
{ | ||
distribution: [0, 1, 5], | ||
name: 'pushPayload', | ||
distribution: [0, 5, 20], | ||
name: 'pushPayload simple-relationship', | ||
suites: [ | ||
require('./push-payload/push-payload') | ||
require('./push-payload-relationships/push-payload') | ||
] | ||
} | ||
); | ||
|
||
require('./runner')( | ||
{ | ||
distribution: [0, 5, 100], | ||
name: 'pushPayload simple-relationship', | ||
distribution: [0, 5, 20], | ||
name: 'pushPayload self-relationship', | ||
suites: [ | ||
require('./push-payload-relationships/push-payload') | ||
require('./push-payload-relationships-self/push-payload') | ||
] | ||
} | ||
); |
66 changes: 66 additions & 0 deletions
66
benchmarks/micro/push-payload-relationships-self/push-payload.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
var name = 'pushPayload relationship-simple (complex-self)'; | ||
|
||
function fn() { | ||
store.pushPayload('person', payload); | ||
} | ||
|
||
module.exports.fn = fn; | ||
module.exports.name = name; | ||
module.exports.setup = function() { | ||
function generatePeople(from, to) { | ||
var result = []; | ||
|
||
for (var i = from; i < to; i++) { | ||
result.push({ | ||
id: i, | ||
firstName: Math.random().toString(36).substring(7), | ||
lastName: Math.random().toString(36).substring(7), | ||
age: Math.random() * 100, | ||
born: Math.random() * 1000, | ||
isInDebt: Math.round(Math.random(0, 1)), | ||
description: Math.random().toString(36).substring(7), | ||
friends: [i + 1, i + 2, i + 3, i + 4, i + 5, i +6, i + 7, to + i + 1, to + i + 2, to + i + 3, to + i + 4, to +i + 5] | ||
}); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
if (!this.____setup) { | ||
var Person = DS.Model.extend({ | ||
firstName: DS.attr(), | ||
lastName: DS.attr(), | ||
friends: DS.hasMany('person', { async: true }) | ||
}); | ||
|
||
var container = new Ember.Container(); | ||
|
||
container.register('store:main', DS.Store); | ||
container.register('model:person', Person); | ||
container.register('serializer:application', DS.RESTSerializer); | ||
container.register('adapter:application', DS.RESTAdapter); | ||
|
||
var store = container.lookup('store:main'); | ||
|
||
// ... TODO: why does benchmark JS do crazy shit | ||
Object.defineProperty(this, '____setup', { | ||
enumerable: false, | ||
value:{ | ||
id: 0, | ||
Person: Person, | ||
container: container, | ||
store: store | ||
}} | ||
); | ||
} | ||
|
||
var setup = this.____setup; | ||
var payload, id, type, attrs; | ||
var store = setup.store; | ||
|
||
store.typeMapFor('person').records.length = 0; | ||
|
||
payload = { | ||
people: generatePeople(0, this.distribution) | ||
}; | ||
} |