Skip to content

Instantly share code, notes, and snippets.

@jnwheeler44
Created October 27, 2012 01:16
Show Gist options
  • Save jnwheeler44/3962557 to your computer and use it in GitHub Desktop.
Save jnwheeler44/3962557 to your computer and use it in GitHub Desktop.
[7] pry(main)> range = ((Date.today - 1000.years)..(Date.today + 1000.years))
=> Sun, 26 Oct 1012..Mon, 26 Oct 3012
[11] pry(main)> target = (Date.today + 999.years)
=> Sat, 26 Oct 3011
[12] pry(main)> Benchmark.measure { range.include? target }
=> 0.410000 0.000000 0.410000 ( 0.411619)
[13] pry(main)> Benchmark.measure { range === target }
=> 0.410000 0.000000 0.410000 ( 0.413075)
[14] pry(main)> Benchmark.measure { range.cover? target }
=> 0.000000 0.000000 0.000000 ( 0.000010)
Calculating -------------------------------------
include 1 i/100ms
=== 1 i/100ms
cover 23902 i/100ms
-------------------------------------------------
include 2.4 (±0.0%) i/s - 13 in 5.386076s
=== 2.4 (±0.0%) i/s - 13 in 5.326941s
cover 2715335.3 (±1.5%) i/s - 13576336 in 5.000979s
=> [ include 2.4 (±0.0%) i/s - 13 in 5.386076s,
=== 2.4 (±0.0%) i/s - 13 in 5.326941s,
cover 2715335.3 (±1.5%) i/s - 13576336 in 5.000979s]
[18] pry(main)> target = Date.today - 999.years
=> Mon, 26 Oct 1013
[19] pry(main)> Benchmark.measure { range.include? target }
=> 0.000000 0.000000 0.000000 ( 0.000194)
[20] pry(main)> Benchmark.measure { range === target }
=> 0.000000 0.000000 0.000000 ( 0.000295)
[21] pry(main)> Benchmark.measure { range.cover? target }
=> 0.000000 0.000000 0.000000 ( 0.000008)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment