[Haskell] Re: Probably a trivial thing for people knowing Haskell
Friedrich
frido at q-software-solutions.de
Tue Oct 21 06:10:49 EDT 2008
the posted codes runs in constant memory, so yes that make it
possible that the stuff runs. That's really nice. Howerver the time is
drastically bad
Even the ruby solution need just
check_downloads/check_downloads.rb . 1,25s user 0,06s system 99% cpu
1,322 total
Here's the ruby code
#!/usr/bin/ruby
sum = 0;
count = 0;
if (ARGV[0]) then
Dir.chdir(ARGV[0])
else
Dir.chdir("Mail/Administration")
end
Dir["[0-9]*"].each { |file |
fh = File.open(file)
while line = fh.gets
if line =~ /(\d+) Windows executable/
num = $1.to_i
#log.printf("file_name = %s, num = %d\n", file, num);
sum += num
count += 1
end
end
fh.close
}
printf("%d downloads in %d days = %.2f downlaods/day", sum, count, Float(sum)/count)
but the haskell solution:
./chk_dwlds 17,71s user 0,11s system 99% cpu 17,836 total
Ruby is surely not the speed king of scripting languages, but what
Haskell delivers is "way worse"....
Howerver at least it doesn not crash any longer....
Regards
Friedrich
More information about the Haskell
mailing list