-
Notifications
You must be signed in to change notification settings - Fork 70
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 #244 from trailsjs/243-move-performance-test
Move the performance cases to another new performance test suite
- Loading branch information
Showing
6 changed files
with
161 additions
and
24 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "trails/test" | ||
} |
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,131 @@ | ||
'use strict' | ||
|
||
const assert = require('assert') | ||
const lib = require('../../lib') | ||
const smokesignals = require('smokesignals') | ||
|
||
describe('lib.Pathfinder', () => { | ||
describe('Lifecycle', () => { | ||
const app = new smokesignals.TrailsApp() | ||
const packs = [ | ||
new smokesignals.Trailpack(app, { | ||
trailpack: { | ||
lifecycle: { | ||
configure: { | ||
listen: [ ], | ||
emit: [ 'pack0:configured' ] | ||
}, | ||
initialize: { | ||
listen: [ ], | ||
emit: [ 'pack0:initialized' ] | ||
} | ||
} | ||
} | ||
}, 'pack0'), | ||
|
||
new smokesignals.Trailpack(app, { | ||
trailpack: { | ||
lifecycle: { | ||
configure: { | ||
listen: [ 'pack0:configured' ], | ||
emit: [ 'pack1:configured' ] | ||
}, | ||
initialize: { | ||
emit: [ 'pack1:initialized', 'pack1:custom' ] | ||
} | ||
} | ||
} | ||
}, 'pack1'), | ||
|
||
new smokesignals.Trailpack(app, { | ||
trailpack: { | ||
lifecycle: { | ||
configure: { | ||
listen: [ 'pack1:configured' ], | ||
emit: [ 'pack2:configured' ] | ||
}, | ||
initialize: { | ||
listen: [ 'pack1:initialized', 'pack1:custom' ], | ||
emit: [ 'pack2:initialized' ] | ||
} | ||
} | ||
} | ||
}, 'pack2'), | ||
|
||
new smokesignals.Trailpack(app, { | ||
trailpack: { | ||
lifecycle: { | ||
configure: { | ||
listen: [ 'pack2:configured' ], | ||
emit: [ 'pack3:configured' ] | ||
}, | ||
initialize: { | ||
listen: [ 'pack2:initialized', 'pack1:custom' ], | ||
emit: [ 'pack3:initialized' ] | ||
} | ||
} | ||
} | ||
}, 'pack3'), | ||
|
||
new smokesignals.Trailpack(app, { | ||
trailpack: { | ||
lifecycle: { | ||
// dependency with no route to source | ||
configure: { | ||
listen: [ 'packX:configured' ], | ||
emit: [ 'pack4:configured' ] | ||
}, | ||
// dependency on pack with circular dependency | ||
initialize: { | ||
listen: [ 'pack5:initialized', 'pack0:initialized' ] | ||
} | ||
} | ||
} | ||
}, 'pack4'), | ||
|
||
// circular dependency | ||
new smokesignals.Trailpack(app, { | ||
trailpack: { | ||
lifecycle: { | ||
configure: { | ||
listen: [ 'pack5:configured' ], | ||
emit: [ 'pack5:configured' ] | ||
}, | ||
initialize: { | ||
listen: [ 'pack4:initialized' ], | ||
emit: [ 'pack5:initialized' ] | ||
} | ||
} | ||
} | ||
}, 'pack5') | ||
] | ||
|
||
describe('#isComplete', () => { | ||
it('should execute in under 5ms (n=6, with errors)', () => { | ||
const t0 = process.hrtime() | ||
const path = [ packs[0], packs[1], packs[2], packs[3], packs[4], packs[5] ] | ||
|
||
const complete = lib.Pathfinder.isComplete(path) | ||
|
||
const t1 = process.hrtime(t0) | ||
const t = t1[1] / 1e6 | ||
|
||
assert(t < 5, `actual time: ${t} ms`) | ||
assert(!complete) | ||
}) | ||
it('should execute in under 2ms (n=4, no errors)', () => { | ||
const t0 = process.hrtime() | ||
const path = [ packs[0], packs[1], packs[2], packs[3] ] | ||
|
||
const complete = lib.Pathfinder.isComplete(path) | ||
|
||
const t1 = process.hrtime(t0) | ||
const t = t1[1] / 1e6 | ||
|
||
assert(t < 2, `actual time: ${t} ms`) | ||
assert(complete) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
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,6 @@ | ||
--reporter spec | ||
--recursive | ||
--full-trace | ||
--no-exit | ||
--check-leaks | ||
--globals app |
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,20 @@ | ||
const smokesignals = require('smokesignals') | ||
|
||
module.exports = { | ||
api: { | ||
|
||
}, | ||
config: { | ||
main: { | ||
paths: { | ||
root: __dirname | ||
} | ||
}, | ||
log: { | ||
logger: new smokesignals.Logger('silent') | ||
} | ||
}, | ||
pkg: { | ||
|
||
} | ||
} |
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