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
Improve Array#concat performance if only one argument is given #1634
Closed
Conversation
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
This is very similar with ruby#1631 If only one argument is given, this will concatenate the array without generating temporary Array object. Array#concat will be faster around 19% * Before Calculating ------------------------------------- Array#concat 2.187M (± 3.5%) i/s - 10.926M in 5.002829s * After Calculating ------------------------------------- Array#concat 2.598M (± 1.8%) i/s - 13.008M in 5.008201s * Test code require 'benchmark/ips' Benchmark.ips do |x| x.report "Array#concat" do |i| other = [4] i.times { [1, 2, 3].concat(other) } end end
nurse
approved these changes
May 26, 2017
Watson1978
added a commit
to Watson1978/ruby
that referenced
this pull request
Jul 27, 2017
This is very similar with ruby#1634 If only one argument is given, this will prepend the string without generating temporary object. ``` String#prepend -> 47.5 % up ``` ### Before ``` String#prepend 1.517M (± 1.8%) i/s - 7.614M in 5.019819s ``` ### After ``` String#prepend 2.236M (± 3.4%) i/s - 11.234M in 5.029716s ``` ### Test code ``` require 'benchmark/ips' Benchmark.ips do |x| x.report "String#prepend" do |loop| loop.times { "!".prepend("hello") } end end ```
Watson1978
added a commit
to Watson1978/ruby
that referenced
this pull request
Oct 14, 2017
This is very similar with ruby#1634 If only one argument is given, this will prepend the string without generating temporary object. ``` String#prepend -> 47.5 % up ``` ``` String#prepend 1.517M (± 1.8%) i/s - 7.614M in 5.019819s ``` ``` String#prepend 2.236M (± 3.4%) i/s - 11.234M in 5.029716s ``` ``` require 'benchmark/ips' Benchmark.ips do |x| x.report "String#prepend" do |loop| loop.times { "!".prepend("hello") } end end ```
Watson1978
added a commit
to Watson1978/ruby
that referenced
this pull request
Oct 27, 2017
This is very similar with ruby#1634 If only one argument is given, this will prepend the string without generating temporary object. ``` String#prepend -> 47.5 % up ``` ``` String#prepend 1.517M (± 1.8%) i/s - 7.614M in 5.019819s ``` ``` String#prepend 2.236M (± 3.4%) i/s - 11.234M in 5.029716s ``` ``` require 'benchmark/ips' Benchmark.ips do |x| x.report "String#prepend" do |loop| loop.times { "!".prepend("hello") } end end ```
matzbot
pushed a commit
that referenced
this pull request
Oct 27, 2017
…given * string.c (rb_str_prepend_multi): Prepend the string without generating temporary String object if only one argument is given. This is very similar with #1634 String#prepend -> 47.5 % up [Fix GH-1670] [ruby-core:82195] [Bug #13773] * Before String#prepend 1.517M (± 1.8%) i/s - 7.614M in 5.019819s * After String#prepend 2.236M (± 3.4%) i/s - 11.234M in 5.029716s * Test code require 'benchmark/ips' Benchmark.ips do |x| x.report "String#prepend" do |loop| loop.times { "!".prepend("hello") } end end git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
mrkn
pushed a commit
to mrkn/ruby
that referenced
this pull request
Dec 1, 2017
…given * string.c (rb_str_prepend_multi): Prepend the string without generating temporary String object if only one argument is given. This is very similar with ruby#1634 String#prepend -> 47.5 % up [Fix rubyGH-1670] [ruby-core:82195] [Bug #13773] * Before String#prepend 1.517M (± 1.8%) i/s - 7.614M in 5.019819s * After String#prepend 2.236M (± 3.4%) i/s - 11.234M in 5.029716s * Test code require 'benchmark/ips' Benchmark.ips do |x| x.report "String#prepend" do |loop| loop.times { "!".prepend("hello") } end end git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/trunk@60480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is very similar with #1631
If only one argument is given, this will concatenate the array without
generating temporary Array object.
Array#concat will be faster around 19%