Running Coverband with a significantly big project (I'm currently working on one wtih ~4600 files) may get quite slow. While profiling the project, I found that one big culprit is the Results class, where there's a lot of O(n) lookup operations that could but are not currently being memoized.
This PR adds such optimization: replacing find operations for hash lookups (so only the first lookup of eager and runtime type results is slow - due to building the lookup hash)
This optimization alone brought the following load improvement to the coverage report page:
# NOTE: running on a HashRedisStore with ~4600 files
# command used:
Benchmark.measure do
Coverband::Reporters::Web.new.tap do |cov|
cov.instance_variable_set(:@request,Rack::Request.new(Rack::MockRequest.env_for("/")))
end.index
nil
end
# before
# => #<Benchmark::Tms:0x00007f74bf2ee240 @cstime=0.0, @cutime=0.0, @label="", @real=33.93276486300056, @stime=3.5702559999999997, @total=34.058608, @utime=30.488352>
# after
# => #<Benchmark::Tms:0x00007efe452aa248 @cstime=0.0, @cutime=0.0, @label="", @real=25.779949678000776, @stime=3.301538, @total=25.864683, @utime=22.563145>
Also tested with both this and #499
# with both this and #499
# => #<Benchmark::Tms:0x00007f1374de55b0 @cstime=0.0, @cutime=0.0, @label="", @real=8.71669229300096, @stime=0.7920630000000002, @total=8.723904, @utime=7.931840999999999>
Running Coverband with a significantly big project (I'm currently working on one wtih ~4600 files) may get quite slow. While profiling the project, I found that one big culprit is the
Results
class, where there's a lot of O(n) lookup operations that could but are not currently being memoized.This PR adds such optimization: replacing
find
operations for hash lookups (so only the first lookup ofeager
andruntime
type results is slow - due to building the lookup hash)This optimization alone brought the following load improvement to the coverage report page:
Also tested with both this and #499