-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark.rb
executable file
·36 lines (27 loc) · 988 Bytes
/
benchmark.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
require 'rubygems'
require 'benchmark'
require 'curb'
require 'uri/meta'
URI::Meta::Cache.cache = nil
cached_uris = uncached_uris = []
uncached_uris = []
delete = Curl::Multi.new
(1..50).each do |x|
cached_uris << URI.parse('http://tigris.id.au/')
uncached_uris << URI.parse("http://tigris.id.au/#{x}")
c = Curl::Easy.new("http://www.metauri.com/delete?uri=#{uncached_uris.last.to_s}")
c.on_complete{|curl| print '.'}
delete.add(c)
end
print ' performing cache clear '
clear = Benchmark.realtime{ delete.perform }
puts " #{clear}"
## TODO: figure out why uncached is faster when X > pool size, but way less when X < pool size
print ' calculating cached time '
cached = Benchmark.realtime{ URI::Meta.multi(cached_uris){|m| print '.'}}
puts " #{cached}"
print 'calculating uncached time '
uncached = Benchmark.realtime{ URI::Meta.multi(uncached_uris){|m| print '.'}}
puts " #{uncached}"