mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Log 10 longest running specs
This commit is contained in:
31
vendor/jasmine-helper.coffee
vendored
31
vendor/jasmine-helper.coffee
vendored
@@ -6,6 +6,7 @@ module.exports.runSpecSuite = (specSuite, logErrors=true) ->
|
||||
nakedLoad 'jasmine-focused'
|
||||
|
||||
$ = require 'jquery'
|
||||
_ = require 'underscore'
|
||||
|
||||
$('body').append $$ ->
|
||||
@div id: 'jasmine-content'
|
||||
@@ -18,5 +19,35 @@ module.exports.runSpecSuite = (specSuite, logErrors=true) ->
|
||||
require specSuite
|
||||
jasmineEnv = jasmine.getEnv()
|
||||
jasmineEnv.addReporter(reporter)
|
||||
|
||||
class TimeReporter extends jasmine.Reporter
|
||||
|
||||
timedSpecs: []
|
||||
|
||||
reportSpecStarting: (spec) ->
|
||||
stack = [spec.description]
|
||||
suite = spec.suite
|
||||
while suite
|
||||
stack.unshift suite.description
|
||||
suite = suite.parentSuite
|
||||
|
||||
@time = new Date().getTime()
|
||||
@description = stack.join(' -> ')
|
||||
|
||||
reportSpecResults: ->
|
||||
return unless @time? and @description?
|
||||
@timedSpecs.push
|
||||
description: @description
|
||||
time: new Date().getTime() - @time
|
||||
@time = null
|
||||
@description = null
|
||||
|
||||
reportRunnerResults: ->
|
||||
console.log '10 longest running specs:'
|
||||
for spec in _.sortBy(@timedSpecs, (spec) -> -spec.time)[0...10]
|
||||
console.log "#{spec.time}ms"
|
||||
console.log spec.description
|
||||
|
||||
jasmineEnv.addReporter(new TimeReporter())
|
||||
jasmineEnv.specFilter = (spec) -> reporter.specFilter(spec)
|
||||
jasmineEnv.execute()
|
||||
|
||||
Reference in New Issue
Block a user