Created
July 2, 2019 13:43
-
-
Save hkurokawa/c973f73a05dcfa23c6b5bb41017cdd1f 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
require 'benchmark' | |
require 'priority_queue' | |
#require 'profile' | |
M = 64 | |
N = 153600 | |
pq = PriorityQueue.new | |
list = Array.new(N) { |i| i }.shuffle | |
time = Benchmark.realtime do | |
(1..M).each { | |
list.each { |i| pq.push(i, i) } | |
(1..N).each { pq.delete_min } | |
} | |
end | |
p time # 25.72565756700351 | |
# | |
# Linux 4.15.0-54-generic #58-Ubuntu SMP Mon Jun 24 10:55:24 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux | |
# ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment