The problem of wide finder was coined by Tim Bray, and is summarized in http://www.tbray.org/ongoing/When/200x/2007/09/20/Wide-Finder
The task is to read an Apache logfile and figure out which pages have been fetched the most.
The reference Ruby code
# 11 lines
counts = {}
counts.default = 0
ARGF.each_line do |line|
if line =~ %r{GET /ongoing/When/\d\d\dx/(\d\d\d\d/\d\d/\d\d/[^ .]+) }
counts[$1] += 1
end
end
keys_by_count = counts.keys.sort { |a, b| counts[b] <=> counts[a] }
keys_by_count[0 .. 9].each do |key|
puts "#{counts[key]}: #{key}"
end
Bray's original idea was to check if Erlang is good option for this problem on multi-core platforms.
Read more ...
No comments:
Post a Comment