Move tools/profile to new internal code_metrics gem

Merging development from https://github.com/bf4/code_metrics
and https://github.com/rails/rails/pull/11148
back into Rails

The new gem
- is not part of the Rails release cycle
- is used internally by Rails
- does not depend on Rails