From: Brian Candler Date: 2003-04-08T07:04:25+09:00 Subject: Re: Newbie question:read file speed On Tue, Apr 08, 2003 at 06:32:29AM +0900, Daniel Berger wrote: > Does running your code through the profiler provide any insight? Not greatly: $ ruby -rprofile x.rb /usr/share/dict/words Elapsed = 166.156065 % cumulative self self total time seconds seconds calls ms/call ms/call name 66.76 93.20 93.20 1 93203.12 139601.56 IO#each_line 33.23 139.60 46.40 235881 0.20 0.20 Fixnum#+ 0.00 139.60 0.00 1 0.00 0.00 Float#to_s 0.00 139.60 0.00 1 0.00 0.00 Array#[] 0.00 139.60 0.00 2 0.00 0.00 IO#write 0.00 139.60 0.00 1 0.00 0.00 Kernel.puts 0.00 139.60 0.00 1 0.00 139617.19 #toplevel 0.00 139.60 0.00 2 0.00 0.00 Time#now 0.00 139.60 0.00 1 0.00 0.00 Float#- 0.00 139.60 0.00 1 0.00 0.00 File#open 0.00 139.60 0.00 2 0.00 0.00 Time#to_f 0.00 139.60 0.00 1 0.00 0.00 String#+ I can't do Perl without some serious work: ===> Configuring for p5-Devel-Profiler-0.04 Perl 5.006 required--this is only version 5.00503, stopped at ./Makefile.PL line 4. BEGIN failed--compilation aborted at ./Makefile.PL line 4. *** Error code 255 However I suspect it would say the same: that it spends most of its time running a fetch-next-line loop, and a bit of time adding one to a counter :-) What it really needs is a C profiler. Regards, Brian.