mtkopone / scct

Scala Code Coverage Tool
http://mtkopone.github.com/scct/
Apache License 2.0
129 stars 39 forks source link

Performance optimizations #26

Closed gbasler closed 12 years ago

gbasler commented 12 years ago

I'm trying to run scct on our code base (13 modules, 100K LOC) and I found some lock contention and performance problems. I optimized as much as I could with my limited understanding of how scct works. A test run takes 8 minutes whereas scct:test takes over 150 minutes. Is it possible to replace the hash table lookup in Coverage with a simple array access or something? What does this lookup actually do?

mtkopone commented 12 years ago

I haven't had a codebase large enough to test on, so performance has never really been verified.

Thanks a lot.

mtkopone commented 12 years ago

Oh, and apologies for the seriously late response...

mtkopone commented 12 years ago

A couple of issues came up:

1) Tests didn't compile, and some were broken. Fixing these was pretty trivial, tho.

2) The eating-my-own-dogfood-bit - running "sbt scct:test" on scct itself - wound up in an infinite loop when trying to initialise itself. The most straight-forward way to fix this is to move some of the "uncovered"-annotations around and to add a boolean check into Coverage.invoked() to check whether initialisation is complete. I'm assuming that if I change invoked to:

@uncovered def invoked(id: Int) {
    if (!started) return
    counters(id) +=1
 }

...it won't make very much of a dent in the performance?

mtkopone commented 12 years ago

With the above tweaks, this is now included in the binaries at:

http://mtkopone.github.com/scct/maven-repo/

Let me know of any problems... And thanks again.

gbasler commented 12 years ago

Thanks for merging my request ;-)

Sorry about the broken unit tests - I run them after my first improvements but forgot to run them before the last commit...