Skip to content

Instantly share code, notes, and snippets.

@tomascco
Created July 30, 2020 17:49
Show Gist options
  • Save tomascco/1fbdf9d7d7abee2d2a0b437f8617c01f to your computer and use it in GitHub Desktop.
Save tomascco/1fbdf9d7d7abee2d2a0b437f8617c01f to your computer and use it in GitHub Desktop.
Código do benchmark - aula 9
require_relative 'quickselect'
require 'benchmark'
array = (1..10_000_000).to_a.shuffle
n = 100
p = 123_423
Benchmark.bmbm do |bench|
bench.report('quicksort') do
quicksort(array, 0, array.size - 1, LomutoPartition)
array[p]
end
bench.report('quickselect') do
quickselect(array, p, 0, array.size - 1)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment