Created
October 27, 2012 01:16
-
-
Save jnwheeler44/3962557 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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