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.
Add a specialized instruction for
.nil?calls #112New 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
Uh oh!
There was an error while loading. Please reload this page.
Add a specialized instruction for
.nil?calls #112Changes from 1 commit
47500f21361967bbe157f7f10da97ef08563fdb9632c22051f4064a058065b81b59ed90eafa1d4b345f9f103ed8036039c5349aa2f73ea333a1d355574e8a6de0f1925e0d27a5a42dcac781b1bc20445ab452c030c6c9376aab77ac184a1ca8e4b7b325d54634019a2ca524bc71d5b4c8e37ef700dc0dae2f987e75fb0a976c6cf219d592d8deabcde988048d8e23a6d45d4486ab95fbed2f2b4f487e5b0965bb6af07e07cd372f80e23e0c416ead4bdec1ad9b28eef97808e21b82c8714cf95c877938291aae657291fefb8242bc47c0cab77f33198ac9a7b4d60a58385ea91001f18756fcf98311007b38e3c6578bc6cd9790b77d40d8b3a027c4ba036a8ad4c402918bce9959d6ce40b82641fd461de9dda0a0d7fdf45c8ee44f8ca32024ec5b39e644e2d63160a86eef80dcf93f98dd0e33fe14f576547f574182ae14a44ad9aae75079fba3e76e004afd517f7f90a7093a3e8d4ff0a16ff9de1832857b7bfa71d21f3bf2f84b7e26776ceeb153c945d11d304f7777bb79b8a38eff56b957e1392b8281fc3bee7b5b91c584dd8d285579523fec824712ee08ea92428ae30bf6a7b10463092bf6461fad1c2b19f75561b9095ff51feda1c9f9a6db2f6cc006b62aa711f3da8d2710bac1ad63232ec6dd01995df44cfabd73d56d6ab087ec90c4bd233f54dac25ff7b6546aed009ec370338c44e8d4f0c03958a0676df31b6f07f7325f7b6c9826c2f295e23afea8db11662c79aba971a4e5690df31715a39f2185108a5d3a227b999680f899fb637dc954cb7b1893c65a9d4b96b0d7c538ba981cce4303556cba48b4debda76c44efa380b0a63c4d938032a50076906ca7dc6698dde5414d6cf077c28882ae462a850be6d8e90f5f5ea0544c1db8446771ab8e53d180f9ec4aa50c8447e33f32957a29f300de6a82b02c151f22de348c968071bf8895aa60ff7cbbc7a86d4ee3b0f9528bb489221ce8b34b7d7d0b1a2edd4f978a15fef46abd328336279cf88bccbf3149e414012d39c58bb7f0f9f02e8a06301b5c276e17b727e373530a9e3b613af1b76eaadf13621d1f98dbce3482a6e3285b40589861f0f71f811a5e630eb048c6f1714b4d8a65af28fee05f397f6a6b21a5ea55f968c7b4bef398e3ee63cfe62a609c2428b8aa974101a759bf9170646177731a6eab49a1da3a313805ef72e6f77747144f9e250884f3b0ed3ceb9e27a50bc9f369c36ef5adc78File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
.nil?callsThis commit adds a specialized instruction for called to `.nil?`. It is about 27% faster than master in the case where the object is nil or not nil. In the case where an object implements `nil?`, I think it may be slightly slower. Here is a benchmark: ```ruby require "benchmark/ips" class Niller def nil?; true; end end not_nil = Object.new xnil = nil niller = Niller.new Benchmark.ips do |x| x.report("nil?") { xnil.nil? } x.report("not nil") { not_nil.nil? } x.report("niller") { niller.nil? } end ``` On Ruby master: ``` [aaron@TC ~/g/ruby (master)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 429.195k i/100ms not nil 437.889k i/100ms niller 437.935k i/100ms Calculating ------------------------------------- nil? 20.166M (± 8.1%) i/s - 100.002M in 5.002794s not nil 20.046M (± 7.6%) i/s - 99.839M in 5.020086s niller 22.467M (± 6.1%) i/s - 112.111M in 5.013817s [aaron@TC ~/g/ruby (master)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 449.660k i/100ms not nil 433.836k i/100ms niller 443.073k i/100ms Calculating ------------------------------------- nil? 19.997M (± 8.8%) i/s - 99.375M in 5.020458s not nil 20.529M (± 7.0%) i/s - 102.385M in 5.020689s niller 21.796M (± 8.0%) i/s - 108.110M in 5.002300s [aaron@TC ~/g/ruby (master)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 402.119k i/100ms not nil 438.968k i/100ms niller 398.226k i/100ms Calculating ------------------------------------- nil? 20.050M (±12.2%) i/s - 98.519M in 5.008817s not nil 20.614M (± 8.0%) i/s - 102.280M in 5.004531s niller 22.223M (± 8.8%) i/s - 110.309M in 5.013106s ``` On this branch: ``` [aaron@TC ~/g/ruby (specialized-nilp)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 468.371k i/100ms not nil 456.517k i/100ms niller 454.981k i/100ms Calculating ------------------------------------- nil? 27.849M (± 7.8%) i/s - 138.169M in 5.001730s not nil 26.417M (± 8.7%) i/s - 131.020M in 5.011674s niller 21.561M (± 7.5%) i/s - 107.376M in 5.018113s [aaron@TC ~/g/ruby (specialized-nilp)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 477.259k i/100ms not nil 428.712k i/100ms niller 446.109k i/100ms Calculating ------------------------------------- nil? 28.071M (± 7.3%) i/s - 139.837M in 5.016590s not nil 25.789M (±12.9%) i/s - 126.470M in 5.011144s niller 20.002M (±12.2%) i/s - 98.144M in 5.001737s [aaron@TC ~/g/ruby (specialized-nilp)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 467.676k i/100ms not nil 445.791k i/100ms niller 415.024k i/100ms Calculating ------------------------------------- nil? 26.907M (± 8.0%) i/s - 133.755M in 5.013915s not nil 25.319M (± 7.9%) i/s - 125.713M in 5.007758s niller 19.569M (±11.8%) i/s - 96.286M in 5.008533s ``` Co-Authored-By: Ashe Connor <[email protected]>Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing