[#18974] Perl/Python/Ruby common backend (Perl6) — ptkwt@...1.aracnet.com (Phil Tomson)

There is a thread about using .NET's CLR as a backend for Ruby, but how

17 messages 2001/08/01

[#19064] ANN: Code Amelioration Contest (presented by Ruby Conference 2001) — David Alan Black <dblack@...>

17 messages 2001/08/03
[#19184] Re: ANN: Code Amelioration Contest (presented by Ruby Conference 2001) — John Carter <john.carter@...> 2001/08/06

On Fri, 3 Aug 2001, David Alan Black wrote:

[#19185] Re: ANN: Code Amelioration Contest (presented by Ruby Conference 2001) — David Alan Black <dblack@...> 2001/08/06

Hello --

[#19186] Re: ANN: Code Amelioration Contest (presented by Ruby Conference 2001) — John Carter <john.carter@...> 2001/08/06

On Mon, 6 Aug 2001, David Alan Black wrote:

[#19125] My 1st look @ ruby: No prototypes and problem with String#gsub — stesch@... (Stefan Scholl)

My first ruby program:

23 messages 2001/08/04

[#19192] Some remarks from a nembie in Ruby — Renaud HEBERT <renaud.hebert@...>

After having read the book "Programming Ruby: The Pragmatic Programmer's

38 messages 2001/08/06

[#19269] Re: Perl/Python/Ruby common backend (Parrot, can Ruby play too?) — ptkwt@...1.aracnet.com (Phil Tomson)

In article <72X97.12093$9i1.972452@e420r-atl1.usenetserver.com>,

50 messages 2001/08/07
[#19349] Re: Perl/Python/Ruby common backend (Parrot, can Ruby play too?) — Mathieu Bouchard <matju@...> 2001/08/08

[#19456] Re: Perl/Python/Ruby common backend (Parrot, can Ruby play too?) — Harry Ohlsen <harryo@...> 2001/08/09

Ned Konz wrote:

[#19451] Re: Help! I'm still confused about threadin g in the ML — "Morris, Chris" <chris.morris@...>

> Is there an Outlook option to turn on In-Reply-To or References

14 messages 2001/08/09
[#19453] Re: Help! I'm still confused about threadin g in the ML — Dave Thomas <Dave@...> 2001/08/09

"Morris, Chris" <chris.morris@snelling.com> writes:

[#19506] the way class variables work — David Alan Black <dblack@...>

Hello --

51 messages 2001/08/10
[#19511] Re: the way class variables work — Chris Uzdavinis <chris@...> 2001/08/11

David Alan Black <dblack@candle.superlink.net> writes:

[#19524] order and freedom in Ruby (was: Re: Re: the way class variables work) — David Alan Black <dblack@...> 2001/08/11

Hello --

[#19517] Why not?: Assigning to self — furufuru@... (Ryo Furue)

Hi there,

55 messages 2001/08/11
[#19689] Re: Why not?: Assigning to self — Ron Jeffries <ronjeffries@...> 2001/08/14

On 13 Aug 2001 20:59:54 -0700, furufuru@ccsr.u-tokyo.ac.jp (Ryo Furue)

[#19694] Re: Why not?: Assigning to self — Ned Konz <ned@...> 2001/08/14

On Tuesday 14 August 2001 05:09 am, Ron Jeffries wrote:

[#19695] Re: Why not?: Assigning to self — ts <decoux@...> 2001/08/14

>>>>> "N" == Ned Konz <ned@bike-nomad.com> writes:

[#19696] Re: Why not?: Assigning to self — Ned Konz <ned@...> 2001/08/14

On Tuesday 14 August 2001 07:51 am, you wrote:

[#19697] Re: Why not?: Assigning to self — ts <decoux@...> 2001/08/14

>>>>> "N" == Ned Konz <ned@bike-nomad.com> writes:

[#19700] Re: Why not?: Assigning to self — Ned Konz <ned@...> 2001/08/14

On Tuesday 14 August 2001 08:27 am, you wrote:

[#19701] Re: Why not?: Assigning to self — ts <decoux@...> 2001/08/14

>>>>> "N" == Ned Konz <ned@bike-nomad.com> writes:

[#19703] Re: Why not?: Assigning to self — Ned Konz <ned@...> 2001/08/14

On Tuesday 14 August 2001 09:05 am, Guy Decoux wrote:

[#19704] Re: Why not?: Assigning to self — ts <decoux@...> 2001/08/14

>>>>> "N" == Ned Konz <ned@bike-nomad.com> writes:

[#19708] Re: Why not?: Assigning to self — Ned Konz <ned@...> 2001/08/14

On Tuesday 14 August 2001 09:27 am, you wrote:

[#19709] Re: Why not?: Assigning to self — ts <decoux@...> 2001/08/14

>>>>> "N" == Ned Konz <ned@bike-nomad.com> writes:

[#19713] Re: Why not?: Assigning to self — Ned Konz <ned@...> 2001/08/14

On Tuesday 14 August 2001 09:45 am, you wrote:

[#19750] Re: Why not?: Assigning to self — matz@... (Yukihiro Matsumoto) 2001/08/15

Hi,

[#19819] Re: Why not?: Assigning to self — Ned Konz <ned@...> 2001/08/15

On Tuesday 14 August 2001 08:14 pm, matz wrote:

[#19852] Re: Why not?: Assigning to self — matz@... (Yukihiro Matsumoto) 2001/08/16

Hi,

[#19857] Re: Why not?: Assigning to self — "Florian G. Pflug" <fgp@...> 2001/08/16

On Thu, Aug 16, 2001 at 11:05:59AM +0900, Yukihiro Matsumoto wrote:

[#19858] Re: Why not?: Assigning to self — matz@... (Yukihiro Matsumoto) 2001/08/16

Hi,

[#19867] Re: Why not?: Assigning to self — "Pit Capitain" <pit@...> 2001/08/16

Just a followup at (my) current end of the thread:

[#19550] Forced garbage collection — Lars Christensen <larsch@...>

14 messages 2001/08/11
[#19562] Re: Forced garbage collection — "Nat Pryce" <nat.pryce@...13media.com> 2001/08/12

From: "Lars Christensen" <larsch@cs.auc.dk>

[#19551] /.ed again — Tobias Reif <tobiasreif@...>

Ruy gets slasdotted again ;)

19 messages 2001/08/11

[#19650] Ruby Newbie mailing list — Michael Pence <mikepence@...>

Hello all.

14 messages 2001/08/13
[#19656] RE: Ruby Newbie mailing list — "Louis Brothers" <lcb134@...> 2001/08/13

We had a similar discussion on the OmniWeb Objective-C mailing list not to

[#19659] Re: Ruby Newbie mailing list — Michael Pence <mikepence@...> 2001/08/13

I appreciate your references to Objectionable-C ;-)

[#19685] Compiling Ruby with cygwin and Tk support — Manuel Zabelt <ng@...>

Hello!

13 messages 2001/08/14

[#19718] General (GUI/license) questions — Ryan Tarpine <rtarpine@...>

First: Kero commented in the description of his new Ruby Agenda program

18 messages 2001/08/14

[#19755] "new" returning nil: how to report the failure of object creation — furufuru@... (Ryo Furue)

Hi there,

14 messages 2001/08/15

[#19758] The GUI poll is in, and the results are surprising — Dave Thomas <Dave@...>

40 messages 2001/08/15
[#19774] Re: The GUI poll is in, and the results are surprising — Lars Christensen <larsch@...> 2001/08/15

On Wed, 15 Aug 2001, Dave Thomas wrote:

[#19784] Re: The GUI poll is in, and the results aresurprising — "Lyle Johnson" <ljohnson@...> 2001/08/15

> Please don't forget what Ruby is all about in this discussion! I think

[#19824] Ruby GUI — "Hal E. Fulton" <hal9000@...>

The concept of a new GUI is somewhat appealing,

16 messages 2001/08/15

[#20033] Ruby Article — Joshua Drake <jd.nospam@...>

Hello,

38 messages 2001/08/20

[#20127] Another Possible RCR - Wrappers via Mixins — Stephen White <spwhite@...>

The main difference between mix-ins and multiple inheritence is (to my understanding) that parent classes do not call child code, but mix-ins do.

15 messages 2001/08/22

[#20135] Bruce Eckel's criticism of Ruby — Ned Konz <ned@...>

Python.org links to http://www.mindview.net/Etc/notes.html#Ruby , saying

24 messages 2001/08/22

[#20183] ++ Operator — kamphausen@... (SKa)

Dear Community,

35 messages 2001/08/23
[#20234] Re: ++ Operator — Dave Thomas <Dave@...> 2001/08/24

matz@ruby-lang.org (Yukihiro Matsumoto) writes:

[#20236] Re: ++ Operator — matz@... (Yukihiro Matsumoto) 2001/08/24

Hi,

[#20209] In Ruby 0 is true but nil is false.. or how to shoot yourself?.. — Guillaume Cottenceau <gc@...>

I have a simple Audio-CD database (using CSV format). I was writing a

11 messages 2001/08/23

[#20254] File.readline(s) — Michael Husmann <michael.husmann@...>

I am reading a 55MB ASCII file by using File.readline(s) which takes on

14 messages 2001/08/24

[#20303] New Windows InstallShield version of Ruby — Andrew Hunt <andy@...>

19 messages 2001/08/24

[#20307] Backwards language — "Sean Middleditch" <elanthis@...>

Greetings,

30 messages 2001/08/24

[ruby-talk:20093] Hash test performance issue

From: Wai-Sun Chia <waisun.chia@...>
Date: 2001-08-22 05:32:29 UTC
List: ruby-talk #20093
Hello Rubyists,
I've bumped into a performance issue when comparing a hash via an 
iterator. Included is the profiler output.

Question:
Why is
	foo = (bar == @bigHumonguosHash) : apple ? orange

Soooo much slower than (almost 100%)

	foo = (bar.id == @bigHumongousHash.id) : apple ? orange

What does ruby do internally when it is asked to compare objects via 
references (especially huge hashes, tens of thousands of records indexed 
by strings)..

p.s. Notice that I just put into use all the "Ruby ways" which were 
discussed earlier? ;-)





-- 
Wai-Sun "Squidster" Chia
RHCE/Professional Services
Linux/Unix/Web Developer

Attachments (2)

area.profile (5.27 KB, text/plain)
=========== ./profiler.rb
 Line time%  time  count
    1                    module LineProfiler__
    2                      lastNow = Start = Process.times[0]
    3                      lastFile = '(toplevel)'
    4                      lastLine = 0
    5                      lastTimes = [0.0]
    6                      lastCounts = [0]
    7                      Files = {}
    8                     
    9                      p = proc { |event, file, line, id, binding, klass|
   10                      if event == 'line'
   11                        now = Process.times[0] 
   12                        lastTimes[ lastLine ] += now - lastNow
   13                        lastCounts[ lastLine ] += 1
   14                        if lastFile != file
   15                          (lastTimes, lastCounts) = Files.fetch(file) { |name|
   16                            Files[name] = [ Array.new(10000, 0.0), Array.new(10000, 0) ]
   17                          }
   18                          lastFile = file
   19                        end
   20                        lastLine = line
   21                        lastNow = Process.times[0]
   22                      end
   23                      }
   24                    
   25                      END {
   26                        set_trace_func nil
   27                        total = Process.times[0] - Start
   28                      total /= 100.0  # convert to percent
   29                        f = STDERR
   30                      for file in Files.keys.sort
   31                        f.printf("=========== %s\n", file)
   32                        f.printf(" Line time%%  time  count\n", file)
   33                        lines = IO.readlines(file)
   34                        (times, counts) = Files[file]
   35                        lines.each_index do |line|
   36                          if counts[line+1] > 0
   37                            f.printf("%5d %3.0f%% %6.2f %6d %s",
   38                            line+1, times[line+1]/total, times[line+1], counts[line+1], 
   39                    lines[line])
   40                          else
   41                            f.printf("%5d                    %s", line+1, lines[line])
   42                          end
   43                        end
   44                      end
   45                        f.close
   46                      }
   47                    
   48                      set_trace_func p
   49                    end
   50                    
   51                    
=========== areacode_lookup.rb
 Line time%  time  count
    1                    #!/usr/bin/ruby
    2                    
    3   0%   0.00      1 class AreaCodeDB
    4   0%   0.00      1   def initialize(filename)
    5   0%   0.00      1     @oldDB = {}
    6   0%   0.00      1     @newDB = {}
    7                    	begin
    8   0%   0.02      1 	  @dbfile = File.new(filename, "r")
    9                    	rescue SystemCallError
   10                    	  puts "Fatal Error: #{$!}"
   11                    	ensure
   12   0%   0.00      1 	  @dbfile.close if @dbfile.nil?
   13   0%   0.00      1 	end
   14                      end
   15   0%   0.00      1   attr_reader :oldDB, :newDB
   16                    
   17   0%   0.00      1   def load
   18   0%   0.00      1 	@dbfile.each_line { |line|
   19   8%   0.37   1663 	  line.chomp!.gsub! /"|x/, ""
   20   9%   0.40   1663 	  area, exchange_name, old_service_num, new_service_num = line.split ','
   21                    
   22   4%   0.17   1663 	  [@newDB, @oldDB].each { |db|
   23                    		# Note that the below is a performance hack...
   24                    		# Apparently comparing object Object#id is SOOO MUCH faster!!
   25                    		# service_num = (db == @newDB) ? new_service_num : old_service_num
   26  23%   1.02   6652 		service_num = (db.id == @newDB.id) ? new_service_num : old_service_num
   27                    		db.store(service_num, [area, exchange_name]) \
   28  29%   1.25   3326 		  if db[service_num].nil?
   29                    	  }
   30                    	}
   31   0%   0.00      1 	@dbfile.close
   32                      end
   33                    
   34   0%   0.00      1   def lookup(number)
   35   0%   0.00      4 	record = []
   36                    	catch :done do
   37   0%   0.00     12 	  (1 .. number.size).each { |i|
   38   0%   0.02     20 		target_service_num = number[0..-i]
   39                    
   40   0%   0.00     20 		[@newDB, @oldDB].each { |db|
   41   0%   0.02     38 		  record = db[target_service_num]
   42   0%   0.00     38 		  throw :done unless record.nil?
   43                    		}
   44                    	  }
   45                    	end
   46   0%   0.00      4 	return record
   47                      end
   48                    end
   49                    
   50   0%   0.00      1 def main
   51   0%   0.00      1   db = AreaCodeDB.new("areacode_db.csv")
   52   0%   0.00      1   db.load
   53                    
   54   0%   0.00      1   puts db.lookup("00320519999").inspect
   55   0%   0.00      1   puts db.lookup("00321412222").inspect
   56   0%   0.00      1   puts db.lookup("00302897333").inspect
   57   0%   0.00      1   puts db.lookup("foobar").inspect
   58                    end
   59                    
   60   0%   0.00      1 main
foo.profile (5.26 KB, text/plain)
=========== ./profiler.rb
 Line time%  time  count
    1                    module LineProfiler__
    2                      lastNow = Start = Process.times[0]
    3                      lastFile = '(toplevel)'
    4                      lastLine = 0
    5                      lastTimes = [0.0]
    6                      lastCounts = [0]
    7                      Files = {}
    8                     
    9                      p = proc { |event, file, line, id, binding, klass|
   10                      if event == 'line'
   11                        now = Process.times[0] 
   12                        lastTimes[ lastLine ] += now - lastNow
   13                        lastCounts[ lastLine ] += 1
   14                        if lastFile != file
   15                          (lastTimes, lastCounts) = Files.fetch(file) { |name|
   16                            Files[name] = [ Array.new(10000, 0.0), Array.new(10000, 0) ]
   17                          }
   18                          lastFile = file
   19                        end
   20                        lastLine = line
   21                        lastNow = Process.times[0]
   22                      end
   23                      }
   24                    
   25                      END {
   26                        set_trace_func nil
   27                        total = Process.times[0] - Start
   28                      total /= 100.0  # convert to percent
   29                        f = STDERR
   30                      for file in Files.keys.sort
   31                        f.printf("=========== %s\n", file)
   32                        f.printf(" Line time%%  time  count\n", file)
   33                        lines = IO.readlines(file)
   34                        (times, counts) = Files[file]
   35                        lines.each_index do |line|
   36                          if counts[line+1] > 0
   37                            f.printf("%5d %3.0f%% %6.2f %6d %s",
   38                            line+1, times[line+1]/total, times[line+1], counts[line+1], 
   39                    lines[line])
   40                          else
   41                            f.printf("%5d                    %s", line+1, lines[line])
   42                          end
   43                        end
   44                      end
   45                        f.close
   46                      }
   47                    
   48                      set_trace_func p
   49                    end
   50                    
   51                    
=========== foo.rb
 Line time%  time  count
    1                    #!/usr/bin/ruby
    2                    
    3   0%   0.00      1 class AreaCodeDB
    4   0%   0.00      1   def initialize(filename)
    5   0%   0.00      1     @oldDB = {}
    6   0%   0.00      1     @newDB = {}
    7                    	begin
    8   0%   0.00      1 	  @dbfile = File.new(filename, "r")
    9                    	rescue SystemCallError
   10                    	  puts "Fatal Error: #{$!}"
   11                    	ensure
   12   0%   0.00      1 	  @dbfile.close if @dbfile.nil?
   13   0%   0.00      1 	end
   14                      end
   15   0%   0.00      1   attr_reader :oldDB, :newDB
   16                    
   17   0%   0.00      1   def load
   18   0%   0.00      1 	@dbfile.each_line { |line|
   19   9%   0.50   1663 	  line.chomp!.gsub! /"|x/, ""
   20   7%   0.38   1663 	  area, exchange_name, old_service_num, new_service_num = line.split ','
   21                    
   22   5%   0.25   1663 	  [@newDB, @oldDB].each { |db|
   23                    		# Note that the below is a performance hack...
   24                    		# Apparently comparing object Object#id is SOOO MUCH faster!!
   25  40%   2.17   6652 		service_num = (db == @newDB) ? new_service_num : old_service_num
   26                    		#service_num = (db.id == @newDB.id) ? new_service_num : old_service_num
   27                    		db.store(service_num, [area, exchange_name]) \
   28  25%   1.33   3326 		  if db[service_num].nil?
   29                    	  }
   30                    	}
   31   0%   0.00      1 	@dbfile.close
   32                      end
   33                    
   34   0%   0.00      1   def lookup(number)
   35   0%   0.00      4 	record = []
   36                    	catch :done do
   37   0%   0.00     12 	  (1 .. number.size).each { |i|
   38   0%   0.00     20 		target_service_num = number[0..-i]
   39                    
   40   0%   0.00     20 		[@newDB, @oldDB].each { |db|
   41   0%   0.00     38 		  record = db[target_service_num]
   42   0%   0.00     38 		  throw :done unless record.nil?
   43                    		}
   44                    	  }
   45                    	end
   46   0%   0.02      4 	return record
   47                      end
   48                    end
   49                    
   50   0%   0.00      1 def main
   51   0%   0.00      1   db = AreaCodeDB.new("areacode_db.csv")
   52   0%   0.00      1   db.load
   53                    
   54   0%   0.00      1   puts db.lookup("00320519999").inspect
   55   0%   0.00      1   puts db.lookup("00321412222").inspect
   56   0%   0.00      1   puts db.lookup("00302897333").inspect
   57   0%   0.00      1   puts db.lookup("foobar").inspect
   58                    end
   59                    
   60   0%   0.00      1 main

In This Thread