New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Mime::Type
#7522
Refactor Mime::Type
#7522
Conversation
Where is the benchmark? |
@@ -4,7 +4,7 @@ | |||
module Mime | |||
class Mimes < Array | |||
def symbols | |||
@symbols ||= map {|m| m.to_sym } | |||
@symbols ||= map(&:to_sym) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only to simplify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to make it faster this is making a little slower:
user system total real
block 1.680000 0.000000 1.680000 ( 1.677796)
sym to 1.840000 0.000000 1.840000 ( 1.850888)
[1.9.3-p194 placar-admin (master)]$ ruby bm.rb
user system total real
block 1.680000 0.000000 1.680000 ( 1.680283)
sym to 1.870000 0.000000 1.870000 ( 1.873345)
[1.9.3-p194 placar-admin (master)]$ ruby bm.rb
user system total real
block 1.700000 0.000000 1.700000 ( 1.707954)
sym to 1.860000 0.000000 1.860000 ( 1.868167)
[1.9.3-p194 placar-admin (master)]$ ruby bm.rb
user system total real
block 1.860000 0.000000 1.860000 ( 1.874244)
sym to 1.930000 0.000000 1.930000 ( 1.933034)
[1.9.3-p194 placar-admin (master)]$ ruby bm.rb
user system total real
block 1.680000 0.010000 1.690000 ( 1.677366)
sym to 1.850000 0.000000 1.850000 ( 1.857757)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've return explicit block.
|
@lexmag I'm fine with the changes. I'm just wondering about the Also coul you add this benchmark in the commit message? |
I've added benchmark in the commit message. |
`parse` method performance improvements - ~27-33%: accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, , pronto/1.00.00, sslvpn/1.00.00.00, */*" Benchmark.measure{ 1_000_0.times { Mime::Type.parse(accept) }} old: 1.430000 0.000000 1.430000 ( 1.440977) new: 0.920000 0.000000 0.920000 ( 0.921813)
Thank you so much. |
parse
method performance improvements - ~27-33%