padrino/padrino-framework — pull request #1027 by skade (2013-01-26 15:01:29+00:00)
Title: padrino-perf: watch out for problematic conditions in your app

First of all: this is alpha, ugly and just a proof of concept that I wanted to show you.

This adds a small binary that allows to watch for know error conditions
and hook into certain aspects at startup time of a padrino application
to gather info.

Currently implemented is suite to detect json and yajl being loaded at the same time and tracking _who_ loaded it.

Also, there is a _horrible_ hack to ensure that load_paths added by padrino-perf are always in front of the `$LOAD_PATH`.

To try a sample run: add `padrino-perf`, `json` and `yajl` to your Gemfile. Run:

```
bundle exec padrino-perf -j -- padrino console
```

This is basically a nice alias for:

```
$ruby -r$PADRINO_PERF_SUITES/json -S padrino console
```
where $ruby is the ruby that called padrino-perf.

Then require `json` and `yajl` in any order:

```
.9.3-p125 :001 > require 'json'
=> true
1.9.3-p125 :002 > require 'yajl'
Concurring json libraries have been loaded. This incurs an
unneccessary memory overhead at should be avoided. Consult the
following call stacks to see who loaded the offending libraries
and contact the authors if necessary:"

============
libname: json
============
/Users/skade/padrino/padrino-framework/padrino-framework/padrino-perf/lib/suites/json.rb:35:in `each'
/Users/skade/padrino/padrino-framework/padrino-framework/padrino-perf/lib/suites/json.rb:35:in `loaded_lib!'
/Users/skade/padrino/padrino-framework/padrino-framework/padrino-perf/lib/suites/yajl/yajl.rb:1:in `'
(irb):2:in `require'
(irb):2:in `irb_binding'
... cont
============
libname: yajl
============
/Users/skade/padrino/padrino-framework/padrino-framework/padrino-perf/lib/suites/json.rb:35:in `each'
/Users/skade/padrino/padrino-framework/padrino-framework/padrino-perf/lib/suites/json.rb:35:in `loaded_lib!'
/Users/skade/padrino/padrino-framework/padrino-framework/padrino-perf/lib/suites/yajl/yajl.rb:1:in `'
(irb):2:in `require'
(irb):2:in `irb_binding'
```

Its not really there yet and the implementation is very straigth-forward and generalized, but the technique can be used to built suites that track memory consumption during loading etc.