mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Don't build description string unless actually logging it
This commit is contained in:
@@ -18,41 +18,44 @@ class TimeReporter extends jasmine.Reporter
|
||||
suites = _.map(window.timedSuites, (key, value) -> [value, key])
|
||||
for suite in _.sortBy(suites, (suite) => -suite[1])[0...number]
|
||||
log " #{suite[0]} (#{suite[1]}ms)"
|
||||
undefined
|
||||
|
||||
logLongestSpecs: (number=10, log) ->
|
||||
log ?= (line) -> console.log(line)
|
||||
log "Longest running specs:"
|
||||
for spec in _.sortBy(window.timedSpecs, (spec) -> -spec.time)[0...number]
|
||||
log spec.description
|
||||
log "#{spec.description} (#{spec.time}ms)"
|
||||
undefined
|
||||
|
||||
reportSpecStarting: (spec) ->
|
||||
@stack = [spec.description]
|
||||
stack = [spec.description]
|
||||
suite = spec.suite
|
||||
while suite
|
||||
@stack.unshift suite.description
|
||||
stack.unshift suite.description
|
||||
@suite = suite.description
|
||||
suite = suite.parentSuite
|
||||
|
||||
reducer = (memo, description, index) ->
|
||||
if index is 0
|
||||
"#{description}"
|
||||
else
|
||||
"#{memo}\n#{_.multiplyString(' ', index)}#{description}"
|
||||
@description = _.reduce(stack, reducer, '')
|
||||
@time = new Date().getTime()
|
||||
|
||||
reportSpecResults: (spec) ->
|
||||
return unless @time? and @stack?
|
||||
return unless @time? and @description?
|
||||
|
||||
duration = new Date().getTime() - @time
|
||||
reducer = (memo, description, index) ->
|
||||
if index is 0
|
||||
"#{description} (#{duration}ms)\n"
|
||||
else
|
||||
"#{memo}#{_.multiplyString(' ', index)}#{description}\n"
|
||||
description = _.reduce(@stack, reducer, '')
|
||||
|
||||
window.timedSpecs.push
|
||||
description: description
|
||||
description: @description
|
||||
time: duration
|
||||
|
||||
if timedSuites[@suite]
|
||||
window.timedSuites[@suite] += duration
|
||||
else
|
||||
window.timedSuites[@suite] = duration
|
||||
|
||||
@time = null
|
||||
@stack = null
|
||||
@description = null
|
||||
|
||||
Reference in New Issue
Block a user