- Setup dummy app files in `test/dummy`
- Setup dummy test server `bin/serve_dummy
- Note: Serializer caching can be completely disabled by passing in
`CACHE_ON=off bin/serve_dummy start` since Serializer#_cache is only
set at boot.
- run with
- ./bin/bench
- `bin/bench` etc adapted from ruby-bench-suite
- target files are `test/dummy/bm_*.rb`. Just add another to run it.
- benchmark cache/no cache
- remove rake dependency that loads unnecessary files
- remove git gem dependency
- Running over revisions to be added in subsequent PR
Adding a benchmak test structure to help contributors to keep track
of how their PR will impact overall performance.
It enables developers to create test inside of tests/benchmark.
This implementation adds a rake task: ```rake benchmark``` that checkout
one commit before, run the test of tests/benchmark, then mover back to
the last commit and run it again. By comparing the benchmark results between
both commits the contributor will notice if and how much his contribution
will impact overall performance.
Changes:
- Introduce Adapter::get for use by Serializer.adapter
- Move Adapter-finding logic from Adapter::adapter_class into Adapter::get
Introduced interfaces:
- non-inherited methods
```ruby
ActiveModel::Serializer::Adapter.adapter_map # a Hash<adapter_name, adapter_class>
ActiveModel::Serializer::Adapter.adapters # an Array<adapter_name>
ActiveModel::Serializer::Adapter.register(name, klass) # adds an adapter to the adapter_map
ActiveModel::Serializer::Adapter.get(name_or_klass) # raises Argument error when adapter not found
```
- Automatically register adapters when subclassing
```ruby
def self.inherited(subclass)
ActiveModel::Serializer::Adapter.register(subclass.to_s.demodulize, subclass)
end
```
- Preserves subclass method `::adapter_class(adapter)`
```ruby
def self.adapter_class(adapter)
ActiveModel::Serializer::Adapter.get(adapter)
end
```
- Serializer.adapter now uses `Adapter.get(config.adapter)` rather than have duplicate logic
gemspec requires "rails" and "activemodel, ">= 4.0", so testing
on 3.2 will always fail to resolve dependencies.
adds and defaults to Rails 4.2 when RAILS_VERSION is not specified