From: Sascha Ebach Date: 2006-02-28T10:45:52+09:00 Subject: Re: [ANN] FasterCSV 0.1.6 -- With Header Support! I just had a look into the FasterCSV class and I must admit that I didn't expect such a large and highly engineered class. That is a nice piece of work. Nothing I can fully understand in 2 minutes... ;) I ran a profile on the test_data.csv file. $ cat prof.rb require 'faster_csv' require 'profile' FasterCSV.read(ARGV.first) $ ruby prof.rb /lib/ruby/gems/1.8/gems/fastercsv-0.1.9/test/test_data.csv % cumulative self self total time seconds seconds calls ms/call ms/call name 56.47 131.37 131.37 16161 8.13 11.69 String#gsub! 10.04 154.73 23.36 16162 1.45 14.11 Kernel.loop 5.13 166.67 11.94 210287 0.06 0.06 String#count 5.12 178.59 11.92 242415 0.05 0.05 Array#<< 4.86 189.90 11.31 210287 0.05 0.05 Fixnum#zero? 4.55 200.50 10.59 242609 0.04 0.04 String#empty? 4.11 210.06 9.57 210289 0.05 0.05 NilClass#nil? 1.23 212.92 2.85 16162 0.18 14.29 FasterCSV#shift 1.20 215.70 2.79 32322 0.09 0.09 String#sub! 1.03 218.09 2.39 48485 0.05 0.05 Hash#[] 0.96 220.31 2.22 32128 0.07 0.07 String#gsub 0.91 222.43 2.11 16166 0.13 0.19 Class#new 0.76 224.19 1.76 1 1762.00 232640.00 FasterCSV#each 0.66 225.74 1.55 16161 0.10 0.14 Kernel.dup 0.56 227.03 1.30 32128 0.04 0.04 Kernel.nil? 0.44 228.06 1.03 16163 0.06 0.06 Array#initialize 0.41 229.03 0.97 16161 0.06 0.06 Array#empty? 0.41 229.99 0.96 16162 0.06 0.06 IO#gets 0.41 230.95 0.96 16161 0.06 0.06 FasterCSV#header_row? 0.41 231.90 0.95 16162 0.06 0.06 String#+ 0.32 232.64 0.74 16161 0.05 0.05 String#initialize_copy 0.00 232.64 0.00 2 0.00 0.00 String#sub 0.00 232.64 0.00 2 0.00 0.00 FasterCSV#init_converters 0.00 232.64 0.00 1 0.00 0.00 IO#read 0.00 232.64 0.00 1 0.00 0.00 Array#include? 0.00 232.64 0.00 1 0.00 0.00 Hash#initialize 0.00 232.64 0.00 1 0.00 0.00 FasterCSV#close 0.00 232.64 0.00 1 0.00 0.00 Array#last 0.00 232.64 0.00 1 0.00 0.00 Hash#merge 0.00 232.64 0.00 1 0.00 0.00 Exception#backtrace 0.00 232.64 0.00 6 0.00 0.00 Hash#delete 0.00 232.64 0.00 1 0.00 0.00 Kernel.block_given? 0.00 232.64 0.00 1 0.00 0.00 Exception#initialize 0.00 232.64 0.00 1 0.00 0.00 FasterCSV#init_parsers 0.00 232.64 0.00 6 0.00 0.00 Kernel.== 0.00 232.64 0.00 1 0.00 0.00 IO#open 0.00 232.64 0.00 1 0.00 0.00 File#initialize 0.00 232.64 0.00 1 0.00 0.00 Kernel.puts 0.00 232.64 0.00 1 0.00 0.00 Array#length 0.00 232.64 0.00 1 0.00 0.00 Exception#set_backtrace 0.00 232.64 0.00 1 0.00 0.00 IO#pos 0.00 232.64 0.00 2 0.00 0.00 Kernel.method 0.00 232.64 0.00 1 0.00 0.00 String#== 0.00 232.64 0.00 1 0.00 0.00 String#[] 0.00 232.64 0.00 2 0.00 0.00 IO#write 0.00 232.64 0.00 1 0.00 0.00 Kernel.__send__ 0.00 232.64 0.00 1 0.00 0.00 IO#close 0.00 232.64 0.00 2 0.00 232640.00 FasterCSV#read 0.00 232.64 0.00 1 0.00 0.00 IO#seek 0.00 232.64 0.00 1 0.00 0.00 Hash#initialize_copy 0.00 232.64 0.00 1 0.00 232640.00 Enumerable.to_a 0.00 232.64 0.00 4 0.00 0.00 Regexp#escape 0.00 232.64 0.00 1 0.00 0.00 FasterCSV#initialize 0.00 232.64 0.00 2 0.00 0.00 Kernel.instance_variable_set 0.00 232.64 0.00 1 0.00 0.00 Array#first 0.00 232.64 0.00 4 0.00 0.00 Symbol#to_s 0.00 232.64 0.00 1 0.00 0.00 IO#eof? 0.00 232.64 0.00 1 0.00 232640.00 FasterCSV#open 0.00 232.64 0.00 1 0.00 0.00 FasterCSV#init_separators 0.00 232.64 0.00 1 0.00 0.00 Fixnum#to_s 0.00 232.64 0.00 1 0.00 0.00 Hash#empty? 0.00 232.64 0.00 1 0.00 0.00 FasterCSV#init_headers 0.00 232.64 0.00 1 0.00 0.00 Array#pop 0.00 232.64 0.00 2 0.00 0.00 Kernel.is_a? 0.00 232.64 0.00 1 0.00 232640.00 #toplevel I am still trying to find where exactly the bottleneck is. Anyway, it is getting late. I'll have another look tomorrow. Mainly because I want to see if I can actually use RubyInline for something useful. Sa�a Ebach