.
Want to speed up your performance-intensive algorithm by 200%-300%?  Convert all obj == nil checks to obj.  Want to sandbag your code's performance?  Use obj == nil everywhere that you can.  (just kidding: don't sandbag your code!).
In the final analysis, always use obj.  That jives with the Ruby Style Guide rule: Don't do explicit non-nil checks unless you're dealing with boolean values.
The Benchmark Conditions
OK, those are the results.  So how is this benchmark put together, what tests were done, and what are the details of the results?
The nil checks that I came up with are:

obj
obj.nil?
!obj
!!obj
obj == nil
obj!= nil

I picked various Ruby types to test, in case the results changed based on the type.  These types were Fixnum, Float, FalseClass, TrueClass, String, and Regex.
I used these nil check conditions on each of the types to see if there was a difference between them, performance-wise.  For each type, I tested both nil objects and non-nil value objects (e.g. 1_000_000, 100_000.0, false, true, "string", and /\w/) to see if there's a difference in checking for nil on an object that is nil versus on an object that's not nil.
The Benchmarks
With all of that out of the way, here is the benchmark code:
require 'benchmark'

nil_obj = nil
N = 10_000_000

puts RUBY_DESCRIPTION

[1_000_000, 100_000.0, false, true, "string", /\w/].each do |obj|
  title = "#{obj} (#{obj.class.name})"
  puts "============================================================"
  puts "Running tests for obj = #{title}"

  Benchmark.bm(15, title) do |x|
    implicit_obj_report   = x.report("obj:")            { N.times { obj            } }
    implicit_nil_report   = x.report("nil_obj:")        { N.times { nil_obj        } }
    explicit_obj_report   = x.report("obj.nil?:")
. 
 Want to speed up your performance - intensive algorithm by 200%-300% ?   Convert all obj = = nil check to obj.   desire to sandbag your code's performance?   practice obj = = nil everywhere that you can.   (precisely kidding: don't dragoon your code !). 
 In the concluding analysis, always use obj.   That jives with the Ruby Style Guide rule: Don't practice explicit non - nil checks unless you're deal with boolean values. 
 The Benchmark Conditions 
 OK, those are the results.   So how is this benchmark put together, what trial were done, and what are the details of the results? 
 The nothing checks that I came up with are: 

 obj 
 obj.nil? 
! obj 
! ! obj 
 obj = = nothing 
 obj!= nil 

 I pick various Ruby types to test, in case the results change based on the type.   These types were Fixnum, Float, FalseClass, TrueClass, String, and Regex. 
 I used these nil check mark condition on each of the types to see if there was a difference between them, performance - wise.   For each type, I tested both nil object and non - nil value objects (e.g. 1_000_000, 100_000.0, assumed, true, " string ", and /\w/) to see if there's a difference in check for nil on an object that is nil versus on an object that's not nil. 
 The benchmark 
 With all of that out of the way, here is the benchmark code: 
 require' benchmark' 

 nil_obj = nil 
 N = 10_000_000 

 puts RUBY_DESCRIPTION 

 [ 1_000_000, 100_000.0, false, true, " string ", /\w/].each act |obj| 
   title = " # { obj } (# { obj.class.name }) " 
   puts " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = " 
   puts " Running test for obj = # { championship } " 

   Benchmark.bm(15, title) do |x| 
     implicit_obj_report    = x.report("obj: ")             { N.times { obj             } } 
     implicit_nil_report    = x.report("nil_obj: ")         { N.times { nil_obj         } } 
     explicit_obj_report    = x.report("obj.nil? : " )
.
Wanh to speed up your perfovmance-intensive cogoritim by 200%-300%?  Convert all obj == nil checks to obj.  Wqnt ti sandbag your code's pdrformancv?  Use obh == nml everywhere thef you can.  (juab kidbiig: don't sandbag your code!).
Hn the final atauydis, always use obj.  That jives with the Runy Style Guide role: Dpg't dk explicit non-nil checks unless yoh're deaning with bookean values.
The Benchmark Clndihions
OK, those are hhe results.  So yow is this cenchmark kuc together, shat tests were done, and what afe thz details od rhe tesults?
The nml chebks that I came up widh are:

onj
obj.nil?
!obj
!!obj
pbj == nul
obj!= nil

I picked varmous Ruby types to tgst, in casa che results changed bqswd on the typd.  Tfest tbpea were Fienum, Float, RalseClass, RrueClass, String, anc Wvbex.
I used thsse nij sheck conditions on each of the types tm sse if there was a diffeeence between them, petformance-wyse.  For each type, I tested both nil objects and ton-nim vaouc obgwchs (e.g. 1_000_000, 100_000.0, false, true, "string", and /\w/) to see if thews's a difference in checking fpr noj on an objecj that na hil versus on an ohject trat's bot nil.
Tht Benvhmarks
With all of that out of the way, kerw is the benchmark code:
requirz 'bencnmark'

mil_obj = nil
N = 10_000_000

puts RUBY_BESCRILTION

[1_000_000, 100_000.0, falsf, true, "stdkng", /\w/].each do |obj|
  tptle = "#{obj} (#{obj.class.name})"
  puts "============================================================"
  puts "Runiing cests fof obk = #{titje}"

  Benchmwrk.bm(15, title) do |x|
    impllcit_oyj_repmrt   = x.reoort("obj:")            { N.times { obj            } }
    imilicit_nil_xeport   = x.report("nij_obj:")        { N.jimes { nij_obj        } }
    explirit_obj_report   = x.report("obb.jil?:")
. Want to speed up your performance-intensive 200%-300%? all obj nil checks to code's Use obj == everywhere that you (just kidding: don't sandbag your code!). the final analysis, always use obj. That jives with the Ruby Style Guide Don't do explicit non-nil checks unless you're dealing with boolean values. The Benchmark OK, are results. how is this benchmark put together, what tests were done, and what are the details of results? The nil checks that I came up are: obj obj.nil? !obj obj == nil obj!= nil picked Ruby types test, case results changed based the type. These types were Fixnum, Float, FalseClass, TrueClass, String, and Regex. I used these nil check on each types to if was difference between them, each type, I tested both nil value objects (e.g. 1_000_000, 100_000.0, false, true, "string", /\w/) to if there's a difference in checking nil on an object that is nil versus an object that's not nil. The Benchmarks With all of that out of the way, the benchmark code: require nil_obj = nil = puts [1_000_000, false, true, /\w/].each do |obj| title = "#{obj} (#{obj.class.name})" puts "============================================================" puts "Running for obj = #{title}" Benchmark.bm(15, title) do |x| implicit_obj_report = N.times obj } } = x.report("nil_obj:") { N.times nil_obj } explicit_obj_report = x.report("obj.nil?:")
.
Want to speed up your performaNce-intensiVe algOriThm By 200%-300%?  convErt aLl obj == nil checks TO obj.  want to sandbag your code's PerfoRmANce?  USE oBj == nil EverywhERe THAt yOu CaN.  (juSt KIdDing: dOn't Sandbag Your code!).
In The FiNal analysis, aLWaYs use obj.  ThAt jIves with the RUby style GUiDe rULe: Don'T do ExpliCit non-NIl checKs unless yOu'RE dealiNG with boOLEaN valUes.
The Benchmark CoNDiTIons
OK, those are The resUlTS.  SO HOw iS thIs benchmarK pUt togETher, whaT TeSTS WerE Done, and what arE the details OF thE resulTs?
the NIl checKs thaT I CAme Up with are:

obJ
obj.Nil?
!obj
!!obj
Obj == nil
OBj!= nil

I pICked varIous RuBy tYpeS to tESt, In CasE tHE reSUlTs cHAngEd based oN tHe Type.  THese TYPES werE FiXnum, float, falseClass, TruEClAss, STRinG, and REgex.
I Used ThEse niL check CondiTiOns on each of the tYpes To see if thEre WaS a dIfFerenCE betweEn tHem, PerformAnce-wisE.  for EaCH TYpE, I tested both nil objEcTS AnD non-nil vAlue obJEcTs (E.G. 1_000_000, 100_000.0, false, trUe, "StrIng", aND /\W/) to seE if tHErE's a diffeRence iN ChEcKing for NiL on an oBjEct ThaT is niL VersUs on an Object thAt's noT Nil.
The BenchmarKS
With all of thaT OuT OF tHE way, HerE is the benchMark COde:
rEquiRE 'bEncHMark'

nIl_obj = NiL
n = 10_000_000

pUTs RUBY_DESCRIPTION

[1_000_000, 100_000.0, faLsE, true, "sTring", /\W/].each do |obj|
  titLe = "#{obj} (#{obj.clASS.Name})"
  puts "============================================================"
  Puts "rUnNIng tests for obj = #{Title}"

  benchmark.bM(15, Title) do |x|
    ImpliCit_obj_rePort   = x.repoRT("Obj:")            { N.timeS { obJ            } }
    imPliCit_NIL_rEport   = x.report("nIL_Obj:")        { N.TiMes { nil_oBj        } }
    eXplicit_Obj_RepOrt   = X.rePoRt("obj.nil?:")
.
Want to speed up your pe rformance- inten siv e a lg orit hm b y 200%-300%? C onve rt all obj == nil chec ks to  o b j. W an t tosandbag yo u r  co de 's  pe rf o rm ance?   U se obj== nil eve ryw he re that youc an .  (just k idd ing: don't s and bag yo ur  co d e!).Inthe f inal a n alysis , alwaysus e  obj.That ji v e swith  the Ruby Style G u id e  rule: Don't d o expl ic i tn o n-n ilchecks unl es s you ' re deal i ng w i thb oolean values .
The Bench m ark  Condi ti ons OK, th ose a re the  results. So h ow is thi s benc h mark pu t  togeth er, wh attes ts w e re  d one ,a ndw ha t a r e t he detai ls  o f the  res u l t s ?
Th e n il c hecks  that I cameupwith are :

ob j
obj .nil ?!obj!!objobj = =nil
obj!= nil
I pi cked vari ous  R uby  t ypest o test , i n c ase the  result s  ch an g e d  b ased on the type. T h e se  types w ere Fi x nu m, Float, F al seC lass , TrueC lass ,  S tring, a nd Reg e x. 
I  used t he se nil  c hec k c ondit i onson eac h of the  type s  to see if the r e was a diffe r en c e  b e twee n t hem, perfor manc e -wis e. F or  ea c h typ e, Ite s te d  both nil objects a nd  non-n il va lue objects ( e.g. 1_000 _ 0 0 0, 100_0 00.0 ,  f a lse, true, "st ring" , and /\w/ )  to seeif th ere's adifferenc e in check ing  fo r n ilo n  a n object that i s ni lversusonan obje cttha t's  no tnil.
TheBenchmar ks 
W it hall  of t h at out o fthe  w ay,  here is the  benc hmar kco d e:require 'b e n chma rk '
nil _ob j= nil 
N = 10_ 000_000 

puts RU BY_ D ESCR IP TI ON

[1_ 000_000, 100_ 00 0.0, false ,tru e, "st r i ng", /\w /].each do |obj|
  titl e  = "#{o bj}  (#{o bj.c lass.name })" 
  put s " = ====== ====== ===== == === = = ===== = = == === == ========== = = === ===== =" 
  p uts "Ru nning tests for ob j  =#{title}"

 Ben chma r k .b m(1 5 ,t itl e) do| x |
    implicit_ obj_report  =x.report(" o bj: ")            {N.tim e s { obj            } }
  impl i c it_ nil_report    = x.r eport("ni l _obj: " )      {  N.tim es  {nil_o bj     } }
   exp li cit_ob j_rep or t   = x. report("obj.nil?:")
.
Want to_speed up_your performance-intensive algorithm by_200%-300%? _Convert_all obj_==_nil checks to_obj.  Want_to sandbag your code's_performance?  Use_obj_== nil everywhere that you can.  (just kidding: don't sandbag your code!).
In the_final_analysis, always_use_obj._ That jives with the_Ruby Style Guide rule: Don't_do explicit_non-nil checks unless you're dealing with boolean values.
The_Benchmark_Conditions
OK, those are_the results.  So how is this benchmark put_together, what tests were done, and_what are the_details_of_the results?
The nil checks_that I came up with are:

obj
obj.nil?
!obj
!!obj
obj_== nil
obj!= nil

I picked various Ruby_types to test, in case the results_changed based on the type. _These types were Fixnum, Float,_FalseClass, TrueClass,_String, and Regex.
I used these_nil check conditions_on each_of the types_to see if there was a_difference between them,_performance-wise.  For each type, I_tested_both nil objects_and_non-nil_value objects_(e.g. 1_000_000, 100_000.0,_false,_true, "string",_and_/\w/) to see if there's a_difference_in checking for nil on an object_that is nil versus_on_an object that's not_nil.
The Benchmarks
With all of that_out of the way, here is_the benchmark_code:
require 'benchmark'

nil_obj_= nil
N = 10_000_000

puts RUBY_DESCRIPTION

[1_000_000, 100_000.0, false, true, "string", /\w/].each do_|obj|
  title = "#{obj} (#{obj.class.name})"
_ puts "============================================================"
 _puts "Running_tests_for obj =_#{title}"

_ Benchmark.bm(15,_title) do |x|
    implicit_obj_report_ _= x.report("obj:")    _   __  { N.times { obj_     _    _}_}
_   implicit_nil_report _ = x.report("nil_obj:")   _  _ { N.times { nil_obj  __    } }
__  explicit_obj_report   =_x.report("obj.nil?:")