Skip to content

Instantly share code, notes, and snippets.

@utkarshkukreti
Created June 15, 2011 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save utkarshkukreti/1028007 to your computer and use it in GitHub Desktop.
Save utkarshkukreti/1028007 to your computer and use it in GitHub Desktop.
floor vs to_s.size
ruby-1.9.2-p180:001:0>> qb(10**6) { Math.log10(123456789).floor + 1 }
Rehearsal ------------------------------------
1.120000 0.000000 1.120000 ( 1.100062)
--------------------------- total: 1.120000sec
user system total real
1.090000 0.000000 1.090000 ( 1.085366)
# => nil
ruby-1.9.2-p180:002:0>> qb(10**6) { 123456789.to_s.size }
Rehearsal ------------------------------------
0.520000 0.000000 0.520000 ( 0.519032)
--------------------------- total: 0.520000sec
user system total real
0.540000 0.000000 0.540000 ( 0.527882)
# => nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment