-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from stas-sl/perf_test
add performance test for loading models with many children that are already in session
- Loading branch information
Showing
2 changed files
with
58 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
--compilers em:ember-script/register | ||
--reporter list | ||
--recursive | ||
--recursive | ||
--timeout 3000 |
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,56 @@ | ||
describe "rest", -> | ||
|
||
adapter = null | ||
session = null | ||
|
||
beforeEach -> | ||
require('./_shared').setupRest.apply(this) | ||
adapter = @adapter | ||
session = @session | ||
Ep.__container__ = @container | ||
|
||
afterEach -> | ||
delete Ep.__container__ | ||
|
||
context 'many children', -> | ||
|
||
beforeEach -> | ||
|
||
class @Post extends Ep.Model | ||
title: Ep.attr 'string' | ||
comments: Ep.hasMany 'comment' | ||
|
||
@App.Post = @Post | ||
|
||
class @Comment extends Ep.Model | ||
message: Ep.attr 'string' | ||
post: Ep.belongsTo 'post' | ||
|
||
@App.Comment = @Comment | ||
|
||
@container.register 'model:post', @Post | ||
@container.register 'model:comment', @Comment | ||
|
||
it 'loads model with many children to empty session fast', -> | ||
# Tell mocha to highlight testcase if it take longer than this threshold | ||
# As alternative it is possible to set `@timeout 500` to fail the test | ||
@slow 500 | ||
|
||
adapter.r['GET:/posts'] = posts: [{id: 1, title: 'is it fast?', rev: 1, comments: [1..100]}], | ||
comments: ({id: i, message: "message#{i}", post: 1, rev: 1} for i in [1..100]) | ||
|
||
session.query('post').then (posts) -> | ||
expect(posts[0].comments.length).to.eq(100) | ||
|
||
|
||
it 'loads model with many children repeatedly fast when rev is set', -> | ||
# Tell mocha to highlight testcase if it take longer than this threshold | ||
# As alternative it is possible to set `@timeout 2500` to fail the test | ||
@slow 2500 | ||
|
||
adapter.r['GET:/posts'] = posts: [{id: 1, title: 'still fast?', rev: 1, comments: [1..100]}], | ||
comments: ({id: i, message: "message#{i}", post: 1, rev: 1} for i in [1..100]) | ||
|
||
session.query('post').then (posts) -> | ||
session.query('post').then (posts) -> | ||
expect(posts[0].comments.length).to.eq(100) |