NativeSupport is a project whose aim is to identify areas of the ActiveSupport library that lend themselves to optimization with native code implementations, and provide those implementations as API-transparent replacements.
NativeSupport is currently in the experimental stages but I would like to get more people involved and begin releasing it as a gem. Since each native implementation is useful on its own, the project lends itself to incremental releases.
The following methods currently have native code implementations:
-
ActiveSupport::Inflector.camelize
-
ActiveSupport::Inflector.underscore
-
ActiveSupport::Inflector.dasherize
-
ActiveSupport::Inflector.ordinalize
-
ActiveSupport::Inflector.demodulize
-
ActiveSupport::Inflector.constantize
-
ActiveSupport::CoreExtensions::Float::Rounding#round_with_precision
If you’d like to take the code for a spin, here’s how:
$ git clone git://github.com/outoftime/native_support.git $ cd native_support $ ruby extconf.rb $ make $ ruby test.rb
This will run a simple test/benchmarking suite that compares NativeSupport’s implementations to their pure-Ruby equivalents, as well as ensuring that the output is the same for equivalent methods.
If you think this is an interesting project, please contribute! Send me a pull request on GitHub, and if your work looks good, I’ll add you as a committer to the main repo.
This software is released in the public domain. The author(s) relinquish all copyright on this work to the maximum extent permitted by law.