Skip to content

Conversation

lvl0nax
Copy link
Contributor

@lvl0nax lvl0nax commented Apr 28, 2016

def convert_to_reader_name(method_name)
  attr_name = method_name.to_s
  if attr_name.end_with?("=")
    attr_name = attr_name[0..-2]
  end
  attr_name
end

def convert_to_reader_name2(method_name)
  method_name.to_s.chomp('=')
end
Calculating -------------------------------------
convert_to_reader_name         79.413k i/100ms
convert_to_reader_name2       95.023k i/100ms
-------------------------------------------------
convert_to_reader_name     (± 4.9%) i/s -     12.627M
convert_to_reader_name2   (± 4.4%) i/s -     16.629M

Comparison:
convert_to_reader_name2:  3317028.9 i/s
convert_to_reader_name:    2516448.3 i/s - 1.32x slower

@lvl0nax
Copy link
Contributor Author

lvl0nax commented Apr 28, 2016

r? @jeremy

Calculating -------------------------------------
convert_to_reader_name   79.413k i/100ms
convert_to_reader_name2  95.023k i/100ms
-------------------------------------------------
convert_to_reader_name    2.516M (± 4.9%) i/s -     12.627M
convert_to_reader_name2   3.317M (± 4.4%) i/s -     16.629M

Comparison:
convert_to_reader_name2:  3317028.9 i/s
convert_to_reader_name:   2516448.3 i/s - 1.32x slower
@lvl0nax lvl0nax force-pushed the am_refactor_method_convert_to_reader_name branch from e9550f9 to 1aeb6bd Compare April 29, 2016 11:34
@jeremy jeremy closed this in 517cf24 Apr 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants