Skip to content

Instantly share code, notes, and snippets.

@AJFaraday
Created July 31, 2014 09:22
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 AJFaraday/676c6c59c7c922f9d148 to your computer and use it in GitHub Desktop.
Save AJFaraday/676c6c59c7c922f9d148 to your computer and use it in GitHub Desktop.
Why use symbols instead of strings:
irb(main):024:0> Benchmark.measure{1_000_000.times{'hello'}}
=> 0.210000 0.000000 0.210000 ( 0.202565)
irb(main):025:0> Benchmark.measure{1_000_000.times{:hello}}
=> 0.050000 0.000000 0.050000 ( 0.046498)
irb(main):026:0> Benchmark.measure{10_000_000.times{'hello'}}
=> 1.500000 0.000000 1.500000 ( 1.499443)
irb(main):027:0> Benchmark.measure{10_000_000.times{:hello}}
=> 0.380000 0.000000 0.380000 ( 0.379270)
irb(main):028:0> Benchmark.measure{100_000_000.times{'hello'}}
=> 15.410000 0.010000 15.420000 ( 15.421837)
irb(main):029:0> Benchmark.measure{100_000_000.times{:hello}}
=> 3.790000 0.010000 3.800000 ( 3.790588)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment