7

Does anyone know of a production worthy package commercial or OSS that can detect which lines of code have been executed or not?

We're looking around for some tools that can help us detect dead code in a production environment, running Ruby On Rails 1.8.7

-daniel

Daniel
  • 7,006
  • 7
  • 43
  • 49

2 Answers2

3

In Ruby 1.9.2 you could simply measure coverage without a significant impact on performance. In 1.8.7, however, this would slow down things way too much. Instead you could get an overview of what's used using perftools.rb (with the CPUPROFILE_METHODS=1 option). As far as I know it has virtually no impact on application performance and it would allow you to see what methods have been called, although you would not get any information about the different code paths (ifs and loops and whatnot).

psyho
  • 7,142
  • 5
  • 23
  • 24
1

The Code Metrics category in Ruby Toolbox mentions code coverage programs such as rcov, but that only covers code that you test.

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
  • Actually it's pretty easy to use rcov to measure production code coverage http://relevance.github.com/rcov/classes/Rcov/CodeCoverageAnalyzer.html. The only problem is that it slows down the application 4 times or so, so it would not be practical. – psyho Jan 28 '11 at 08:26
  • "...but that only covers code that you test.", wrong, especially with Ruby1.9 you can quite easy get information about code usage in production environment too without performance lost – astropanic May 20 '11 at 10:39
  • @bashman: Have you read this somewhere, or are you talking purely from personal experience? – Andrew Grimm May 20 '11 at 11:01
  • read and used, you can try it with your server on localhost too – astropanic May 23 '11 at 07:23
  • @bashman: I thought that rcov didn't even run that well with Ruby 1.9, let alone worked even better than on 1.8. – Andrew Grimm May 23 '11 at 07:37