Created
December 13, 2013 04:56
-
-
Save araslanov-e/7939940 to your computer and use it in GitHub Desktop.
Тест скорости генерации URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EventsHelperTest < ActionView::TestCase | |
def setup | |
country = Country.create(name: 'Belarus') | |
state = State.create(name: 'Minsk') | |
@event = Event.create(country: country, state: state, name: 'Drinking bear') | |
end | |
def test_url_for | |
n = 10000 | |
Benchmark.bmbm do |x| | |
x.report('string') { n.times { url_for("/events/#{@event.id}") } } | |
x.report('helper') { n.times { url_for(event_path(@event)) } } | |
x.report('hash') { n.times { url_for(controller: 'events', action: 'show', id: @event.id) } } | |
x.report('polymorphic') { n.times { url_for(@event) } } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment