Bundle size vs lines of code

18 Aug 2016

Do you like meaningless metrics? Of course you do! Well, you are in luck. Here is the 'bundle size vs lines of code ratio'. In a Rails app directory, do:

$ ruby -e "p (IO::popen('find .bundle/gems -type f|wc -l').first.split(' ')[0].to_f)/\
(IO::popen('bundle exec rake stats|grep \'e L\'').first.match(/C:\s(\d+)/)[1].to_f)"
5.851159007726718

Most app seem to have a ratio between 5 and 10. The largest ratio I've seen so far is 19 for an internal application; the smallest ratios have been the "legacy" apps with tons of code. Those tend to have lots of dependencies also, but I guess most apps do and so the sheer lines of code count overwhelms it. Any app that uses tzinfo will score higher on this metric since that gem has lots of per-city definition files. Any gem that vendors gems will also skew things, so, there ya go.

You have stopped reading by now, but if you had not, you might ask, "why not bundle size in KB rather than file count?" Well that's what I did first but, libv8-3.16.14.13-x86_64-darwin-14.gem throws that way off.