Spec run duration is wrong when using Spork #475

rymai opened this Issue Oct 17, 2011 · 6 comments


None yet

3 participants

rymai commented Oct 17, 2011


The improvement that "provide more accurate run time by registering start time before code is loaded" is great, but this (commit) cause a problem when Spork is used since the start time is set in the prefork block of Spork and duration will then be calculated from this time so it ends up in always increasing duration time.

Maybe the solution should come from Spork, like setting $rspec_start_time ||= Time.now at the top of the Spork.each_run block (as the temporary fix you gave in this guard-rspec issue?

Thanks in advance!


Thanks for reporting this here.

I don't think using an internal rspec global variable from spork would be a good solution. More likely I'd want something like RSpec.start_recording_time or some such. Any ideas on the name?

@timcharper - do you think it would a reasonable thing for spork to do to call RSpec.start_recording_time (or similar) at the beginning of each run?

rymai commented Oct 17, 2011

You're right about the internal global variable! :)

Maybe RSpec.set_start_time (or RSpec.reset_start_time?) is more appropriate since it will (re)set $rspec_start_time?


I have a related problem, which is that I actually need the spec-only runtime. To monitor Raptor, I plot many metrics across commits, including spec runtime. I don't care about load time for this metric; I just want to know whether the specs themselves get slow.

How about this as a proposed solution to both my problem and the spork one:

  • By default, RSpec shows the spec runtime (as it was before 2.7) and the full runtime (as added in 2.7)
  • Somehow, Spork tells RSpec that it should ignore the full runtime since it doesn't make sense in that case. RSpec may be able to detect this simply based on how it's being run. For example, if Spork isn't running RSpec through its script, that should be easy to detect.

Alternatively, we could restore to the pre 2.7 reporting by default, and add an option to report the load time separately.


I was very tempted to suggest that. I'm torn because I love the idea of putting more emphasis on end-to-end runtime, but it's also nonstandard and not backwards compatible (with my metrics, for example).


Alterate to the previous alternative - make the option "include rspec's boot time in the time report"

@dchelimsky dchelimsky added a commit that closed this issue Oct 30, 2011
@dchelimsky dchelimsky Restore reported run time to begin after files are loaded.
- was causing problems for spork users and others.
- closes #475.

This reverts commit fd04952, with
a couple of minor changes/additions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment