[#18931] notes from a Ruby newbie — Ned Konz <ned@...>
Some initial impressions from a Perl/Smalltalk programmer writing his first
[#18957] Ruby and Unicode — Ned Konz <ned@...>
I haven't dug into the source yet, but it seems that Ruby ignores the fact
[#18959] Using "@" as a method name? — Laurent Julliard <Laurent.Julliard@...>
Let's start with a silly question to warm you up :-))
[#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
Hi,
no guile has no vm,
[#19015] Re: IDE for Ruby — Bob Follek <bfollek@...>
Tobias DiPasquale wrote:
[#19025] 1.6/net errors (stack, igneof) — Tobias Reif <tobiasreif@...>
Hi;
[#19026] YAWN Question (Your Annoying Wandering Newbie) — Matt <matt@...>
Since I have yet to find a comprehensive tutorial for CGI using Ruby, I'm still stumbling around in many respects. (I'm sure they exist in Japanese, but I haven't learned it yet... :/ )
On Thursday 02 August 2001 07:13 am, you wrote:
On Thu, 2 Aug 2001, Ned Konz wrote:
[#19043] SSL in Ruby? — hubert@... (Hubert Hung-Hsien Chang)
Just curious if Ruby library has SSL? I look around and it seems that
[#19059] QNX port — Eli Green <eli.green@...>
Greetings.
from Roland Priem on 2001-08-03 at 09:32:49:
Eli Green [mailto:eli.green@codedogs.ca] wrote:
[#19064] ANN: Code Amelioration Contest (presented by Ruby Conference 2001) — David Alan Black <dblack@...>
On Fri, 3 Aug 2001, David Alan Black wrote:
Hello --
On Mon, 6 Aug 2001, David Alan Black wrote:
Guillaume Cottenceau wrote:
Hello --
[#19086] Re: Code Amelioration Contest (presented by Ruby Conference 2001) — "MikkelFJ" <mikkelj-anti-spam@...1.dknet.dk>
> Try to think of imaginative ways to write unattractive Ruby.
[#19091] Re: ANN: Code Amelioration Contest (presented by Ruby Conference 2001) — pschoenb@... (Patrick Schoenbach)
David Alan Black wrote:
Hello --
A couple of questions.
[#19097] Unbuffered output — Harry Ohlsen <harryo@...>
I'm trying to write a small interactive program that reads commands and
[#19098] Endianness and integer indexing — eric@... (Eric Lee Green)
-----BEGIN PGP SIGNED MESSAGE-----
[#19125] My 1st look @ ruby: No prototypes and problem with String#gsub — stesch@... (Stefan Scholl)
My first ruby program:
Hello --
"MikkelFJ" <mikkelj-anti-spam@post1.dknet.dk> writes:
[#19167] struct and $SAFE — ts <decoux@...>
[#19192] Some remarks from a nembie in Ruby — Renaud HEBERT <renaud.hebert@...>
After having read the book "Programming Ruby: The Pragmatic Programmer's
Lloyd Zusman wrote:
>>>>> "R" == Renaud HEBERT <renaud.hebert@alcatel.fr> writes:
[#19248] Ruby/Tk: how to discard excess messages — "Albert L. Wagner" <alwagner@...>
An auto-repeat key is sending additional messages while method is
[#19253] Trying to get to grips with Ruby threads — "Peter Hickman" <peterhi@...>
I am trying to get to grips with threads in Ruby and I wrote (adapted more
[#19259] ANNOUNCE: socket options library v0.1 — "Nat Pryce" <nat.pryce@...13media.com>
I would like to announce the release of Sockopt 0.1. Sockopt is a package
[#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>,
On Tuesday 07 August 2001 10:37 pm, Mathieu wrote:
At 02:37 PM 8/8/01 +0900, Mathieu Bouchard spewed forth:
Ned Konz wrote:
On Thursday 09 August 2001 02:42 pm, you wrote:
>>>>> "N" == Ned Konz <ned@bike-nomad.com> writes:
On Thursday 09 August 2001 11:27 pm, you wrote:
>>>>> "N" == Ned Konz <ned@bike-nomad.com> writes:
On Fri, 10 Aug 2001, Ned Konz wrote:
[#19272] [META] Who kills the References? — stesch@... (Stefan Scholl)
It's a bit hard to read comp.lang.ruby. Some programs (the mail
[#19282] PATCH: fixed bug in "waitfor" in net/telnet.rb — Lloyd Zusman <ljz@...>
I'm using the Net::Telnet module and I'm quite
[#19283] Help with ternary operator syntax and grammar — furufuru@... (Ryo Furue)
Hi there,
[#19297] Speaking of the ternary operator.... — David Alan Black <dblack@...>
Hello --
[#19306] Virtual list — Sean Middleditch <elanthis@...>
For starts, I'm new to Ruby still, forgive me naivette. (Is that even a word?)
[#19326] WIN32OLE — "Aleksei Guzev" <aleksei.guzev@...>
"Aleksei Guzev" <aleksei.guzev@bigfoot.com> writes:
Assigning to a constant???????????!!!!!!!!!!!!!
"Aleksei Guzev" <aleksei.guzev@bigfoot.com> writes:
Are there global constants and how they are distinguished from locals?
"Aleksei Guzev" <aleksei.guzev@bigfoot.com> writes:
[#19398] XPath... — Sean Chittenden <sean-ruby-talk@...>
Does anyone know of an XPath library for Ruby? I dug through
[#19403] Re: WIN32OLE — "Aleksei Guzev" <aleksei.guzev@...>
#Ruby 1.6.4 IRB:
[#19418] Re: Setting $_ for the current scope — Renald Buter <buter@...>
On Thu, Aug 09, 2001 at 01:41:00PM +0100, ruby-talk@ruby-lang.org wrote:
[#19420] Test — Dave Thomas <Dave@...>
[#19446] Help! I'm still confused about threading in the ML — Dave Thomas <Dave@...>
[#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
"Morris, Chris" <chris.morris@snelling.com> writes:
Hello --
On Fri, 10 Aug 2001, David Alan Black wrote:
[#19506] the way class variables work — David Alan Black <dblack@...>
Hello --
David Alan Black <dblack@candle.superlink.net> writes:
David Alan Black <dblack@candle.superlink.net> writes:
Hello --
Hello --
[#19517] Why not?: Assigning to self — furufuru@... (Ryo Furue)
Hi there,
On 13 Aug 2001 20:59:54 -0700, furufuru@ccsr.u-tokyo.ac.jp (Ryo Furue)
On Tuesday 14 August 2001 05:09 am, Ron Jeffries wrote:
>>>>> "N" == Ned Konz <ned@bike-nomad.com> writes:
On Tuesday 14 August 2001 07:51 am, you wrote:
>>>>> "N" == Ned Konz <ned@bike-nomad.com> writes:
On Tuesday 14 August 2001 08:27 am, you wrote:
>>>>> "N" == Ned Konz <ned@bike-nomad.com> writes:
On Tuesday 14 August 2001 09:05 am, Guy Decoux wrote:
>>>>> "N" == Ned Konz <ned@bike-nomad.com> writes:
On Tuesday 14 August 2001 09:27 am, you wrote:
>>>>> "N" == Ned Konz <ned@bike-nomad.com> writes:
On Tuesday 14 August 2001 09:45 am, you wrote:
Hi,
On Tuesday 14 August 2001 08:14 pm, matz wrote:
Hi,
On Thu, Aug 16, 2001 at 11:05:59AM +0900, Yukihiro Matsumoto wrote:
Hi,
Just a followup at (my) current end of the thread:
"Pit Capitain" <pit@capitain.de> writes:
matz@ruby-lang.org (Yukihiro Matsumoto) writes:
[#19550] Forced garbage collection — Lars Christensen <larsch@...>
From: "Lars Christensen" <larsch@cs.auc.dk>
[#19551] /.ed again — Tobias Reif <tobiasreif@...>
Ruy gets slasdotted again ;)
Interesting (and pleasing) to see that the comments
--- Joel Wilsson <siigron@sii.linuxsweden.nu> wrote:
[#19574] Why not access control for instance and class variables? — ptkwt@...1.aracnet.com (Phil Tomson)
From: ptkwt@shell1.aracnet.com (Phil Tomson)
[#19597] reading characters without waiting for carriage return — "RodZilla" <rodzilla2@...>
Greetings,
[#19604] eRuby Application Server — Lothar Scholz <llothar@...>
After working with Allaires JRUN application server i would ask if
[#19631] () overloading — Ed Sinjiashvili <edsin@...>
Hi there!
[#19641] Array.uniq(!) uses what operator ? — Martin Weber <Ephaeton@...>
[#19647] Re: eRuby Application Server — Tobias DiPasquale <anany@...>
chad fowler wrote:
[#19650] Ruby Newbie mailing list — Michael Pence <mikepence@...>
Hello all.
We had a similar discussion on the OmniWeb Objective-C mailing list not to
I appreciate your references to Objectionable-C ;-)
Michael Pence wrote:
Dave Vandervort wrote:
ptkwt@shell1.aracnet.com (Phil Tomson) writes:
[#19652] String#substr — Sean Chittenden <sean_ca_1979@...>
Perl/C/PHP have substr.... does the ruby equiv
[#19685] Compiling Ruby with cygwin and Tk support — Manuel Zabelt <ng@...>
Hello!
[#19699] class methods and optimizing — Chris Moore <thegrandbrie@...>
Does anyone know what class methods are as opposed to instance methods? Are
[#19715] and in postconditions — Joel Wilsson <siigron@...>
Hi everyone,
[#19718] General (GUI/license) questions — Ryan Tarpine <rtarpine@...>
First: Kero commented in the description of his new Ruby Agenda program
[#19745] Computer Language Shootout... — Sean Chittenden <sean@...>
I know this has shown up here before, but after the /. effect
[#19755] "new" returning nil: how to report the failure of object creation — furufuru@... (Ryo Furue)
Hi there,
stephen.hill@motorola.com (Steve Hill) wrote in message news:<c230c758.0108150708.11d81bf2@posting.google.com>...
[#19758] The GUI poll is in, and the results are surprising — Dave Thomas <Dave@...>
On Wed, 15 Aug 2001, Dave Thomas wrote:
> Please don't forget what Ruby is all about in this discussion! I think
[#19782] TCPServer#accept bug? — "Michel H.G. van de Ven" <michelv@...4.nl>
Ruby 1.6.4
[#19800] Exception handling bug? — <ale@...>
Didn't post this to the bug database, as I'm not completely sure this is a
[#19809] how to speed up hash script? — gerry@... (Gerry Wiener)
I'm in the process of writing a script that will read data from a 17MB
[#19820] Ruby GUI — <avdi@...>
Looking over the archives, it seems this very discussion came up a few months
[#19824] Ruby GUI — "Hal E. Fulton" <hal9000@...>
The concept of a new GUI is somewhat appealing,
[#19905] Keyword arguments (was GUI...) — Joseph McDonald <joe@...>
Hi,
[#19927] [ANN] Ruby Behaviors, v. 0.0.2 — David Alan Black <dblack@...>
Hello --
[#19933] SMTP authentication — Brian Marick <marick@...>
Net::SMTP#start takes either :cram_md5 or :plain. My ISP doesn't like
[#19936] CORBA Ruby mapping — Daisuke KANDA <MAP2303@...>
I agree that common classes like system exceptions, a union type, an
[#19944] RE-ENTRY: ruby Mysql for cygwin — Matthias Lampert <ml@...>
Hi, folks!
[#19960] problem understanding class relationships — Tobias Reif <tobiasreif@...>
Hi;
[#19976] How to do arbitrary super calls? — Ned Konz <ned@...>
In Smalltalk, "super" in a method represents the receiver object (the same
[#19993] pose_as — <jweirich@...>
I was reading someone commenting about Objective C yesterday. They
[#19994] Ruby/Gtk: caveats/help on use of rbbr.rb — Albert Wagner <alwagner@...>
I am re-evaluating Ruby/Gtk. I assume that the gtk-brows, talked of in the
[#20018] Anyone know how to send a BCC e-mail in Ruby? — "Carl Youngblood" <carlyoungblood@...>
I'm trying to send a BCC email in Ruby like this:
[#20033] Ruby Article — Joshua Drake <jd.nospam@...>
Hello,
>>>>> "Joshua" == Joshua Drake <jd.nospam@commandprompt.com> writes:
[#20042] breaking out of nested loops — tromp@... (John Tromp)
I wonder what's the proper way to break out of nested loops,
>>>>> "J" == John Tromp <tromp@daisy.uwaterloo.ca> writes:
At 01:44 AM 8/21/01, you wrote:
Hi Brian,
At 07:06 AM 8/22/01, you wrote:
[#20046] [patch] block memory allocation scheme - bmalloc — Lars Christensen <larsch@...>
[#20056] Regexp for japanese characters — Slava Kravchenko <arachis@...>
Hello, everybody!
[#20102] File.stat not working? — "Roger Lipscombe" <rlipscombe@...>
#!/usr/bin/env ruby
[#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.
Hi,
Cool! I could use that.
On Thu, 23 Aug 2001, Albert Wagner wrote:
[#20135] Bruce Eckel's criticism of Ruby — Ned Konz <ned@...>
Python.org links to http://www.mindview.net/Etc/notes.html#Ruby , saying
On 23 Aug 2001 08:06:01 +0900, Ned Konz wrote:
[#20145] unfair comparison — theschof@... (Alexander Schofield)
[Note to Pythoners, I like Python (I prefer Ruby), but I do sometimes
[#20181] Re: Bruce Eckel's criticism of Ruby — "Dat Nguyen" <thucdat@...>
[#20183] ++ Operator — kamphausen@... (SKa)
Dear Community,
>>>>> "S" == SKa <kamphausen@novelscience.com> writes:
ts <decoux@moulon.inra.fr> writes:
Hi,
matz@ruby-lang.org (Yukihiro Matsumoto) writes:
Hi,
> If we really want "++", (a) is the way to go, but I don't think it's
[#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
[#20210] Inherit singleton method? — "Marco Guay" <mguay@...>
I'm a newbie in Ruby, exploring the language from early this summer with the
[#20225] ordered hash — Joseph McDonald <joe@...>
[#20228] ruby accessing variables it doesn't need to? — Joseph McDonald <joe@...>
[#20254] File.readline(s) — Michael Husmann <michael.husmann@...>
I am reading a 55MB ASCII file by using File.readline(s) which takes on
Hi,
Hi,
[#20280] ODBC under Debian Linux — Massimiliano Mirra <list@...>
Has anyone successfully compiled ruby-odbc under Debian (woody)? I
[#20290] Performance of Substrings — kamphausen@... (SKa)
Dear Ruby Community,
[#20291] new toy: method_var — Brian Fundakowski Feldman <green@...>
After seeing a million examples of overriding methods in classes by aliasing
[#20303] New Windows InstallShield version of Ruby — Andrew Hunt <andy@...>
"MikkelFJ" <mikkelj-anti-spam@post1.dknet.dk> writes:
> That hasn't been our experience with the Cygwin DLL. If
[#20307] Backwards language — "Sean Middleditch" <elanthis@...>
Greetings,
Sean Middleditch <elanthis@users.sourceforge.net> wrote:
On 25 Aug 2001 05:52:34 +0900, Todd Gillespie wrote:
[ date ] 2001/08/25 | Saturday | 04:33 AM
On 25 Aug 2001 06:45:25 +0900, John Beppu wrote:
Sean Middleditch <elanthis@users.sourceforge.net> wrote:
On 25 Aug 2001 08:32:39 +0900, Todd Gillespie wrote:
Hi Sean,
On Sat, Aug 25, 2001 at 04:33:51AM +0900, Sean Middleditch wrote:
[#20312] Re: New Windows InstallShield version of Ruby — Andrew Hunt <andy@...>
>Hey, thanks for the windows update! Including FXRuby was a good idea.
[#20337] Re: Iterators (was Re: ++ Operator) — Dave Thomas <Dave@...>
Brian Marick <marick@visibleworkings.com> writes:
[#20356] Vector graphics — "Aleksei Guzev" <aleksei.guzev@...>
Is there an open crossplatform vector-based graphics file format
[#20432] kanji size — Slava Kravchenko <arachis@...>
Hello, everybody!
[#20441] YACC & lex and Ruby — "Dat Nguyen" <thucdat@...>
[#20448] Re: Backwards language — Sean Middleditch <elanthis@...>
On 28 Aug 2001 05:44:57 +0900, Avi Bryant wrote:
[#20462] recursive lambda forms — theschof@... (Alexander Schofield)
It occurs to me that being able to create recursive lambda forms
[#20474] hml tag removal — "Thomas A. Reilly" <w3gat@...>
[#20508] Question: How to use TCPSocketServer and threads on Win32 — Ville Mattila <mulperi@...>
Hello,
[#20513] Question to the Tk/whatever GUI gurus: displaying trees — Armin Roehrl <armin@...>
Hi,
[#20516] A plea for CPAN in Ruby — "Avdi B.Grimm" <avdi@...>
I know it's bad manners to ask for some non-trivial feature without offering
[#20524] Problem with float numbers — DaVinci <bombadil@...>
Hello.
Hi,
On 29 Aug 2001 23:08:04 +0900, Yukihiro Matsumoto wrote:
[#20528] Ruby, DBI, design — steved-clr@...
Can anyone point me to example Ruby code that uses an SQL database.
[#20553] Multiple args to constructor — "Schaefer, F." <fschaef@...>
Hi again,
[#20581] RE: Relative path — "Barnett, Aaron" <aaron.barnett@...>
[#20585] Weird things with eval — Paul Brannan <pbrannan@...>
(A) If I do this:
Hello --
On Fri, 31 Aug 2001, David Alan Black wrote:
[#20588] Calling class member functions from C++ — jglueck@... (Bernhard Glk)
Hi there!
[#20594] The Rabbit — Dave Thomas <Dave@...>
[#20604] String.subst[!] RCR — "Aristarkh A Zagorodnikov" <xm@...3d.ru>
[#20614] Dynamic generation of class variables? — Renald Buter <buter@...>
Hello,
Hello --
[#20646] Iterating by links — Joel VanderWerf <vjoel@...>
[#20647] net/telnet problems — "Carl Youngblood" <cyoungbl@...>
I'm having a problem with the Net::Telnet class. Any help would be greatly
[ruby-talk:19106] Re: Endianness and integer indexing
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sat, 04 Aug 2001 03:40:12 GMT, Harry Ohlsen <harryo@zip.com.au> wrote:
>> For those wondering why I did this, here is a mod_exp routine
>> for calculating z**n % q for very large numbers such as are used
>> in public key encryption:
>
>Sorry, I can't answer your question, but thanks for the code. I was
>literally just about to write the same thing!
Oh, okay. I've noticed an interesting thing about [] though -- it is
almost as slow as doing a " % 2" on the number!
This especially shows up in the gcd (greatest common denominator) code:
Here is the classic Euclidean algorithm, which involves a division and
thus should be fairly slow (this is part of the Crypto_math module, and
thus gets included in both Integer and Bignum when I do the 'include
Crypto_math' in both of them).
# Find the gcd of two numbers, self and i, using the
# Euclidean algorithm. Seems to work fairly fast!
def gcd(i)
n=self.clone
if n >= i
a=n
b=i.clone
else
a=i.clone
b=n
end
while b > 0
r = a % b
a = b.clone
b= r.clone
end
return a
end
Here is Stein's binary GCD, which has no multiplication or division
in it and thus supposedly will run much faster than the Euclidean
algorithm:
# Stein's binary gcd, for test purposes: Algorithm B from
# Knuth sec. 4.5.2. This is actually slower than the above
# routine at the moment, apparently bigint [] is very slow :-(.
def gcdb(i)
k=0
n=self.clone
if n >= i
u=n
v=i.clone
else
u=i.clone
v=n
end
# Now, test both for even-ness:
while u[0]==0 && v[0]==0
k=k+1
u>>=1
v>>=1
end
# okay, they've been divided by 2**k, and at least one
# of their present values is odd:
if u[0]==1
t=-v
else
t=u
end
while t != 0
while t[0]==0
t>>=1 # halve it.
end
if t > 0
u = t
else
v = -t
end
t = u - v
end
return u * (1 << k)
end
end
Here is a quicky random number generator:
# define a random number of size <self>. <self> is a number of bytes,
# *NOT* a # of bits! This will need to be modified to
# work on anything other than Unix, because it uses /dev/urandom. If you
# are on a Unix without a dev/urandom, such as Solaris, use
# Ocotillo (http://ocotillo.sourceforge.net) as your PRNG.
def random()
n=self.clone
fh=open("/dev/urandom","r")
if (!fh)
fh=open("/dev/orandom","r") # optional place.
end
if (!fh)
raise "NO RANDOM DEVICE"
end
i=0
s=fh.read(n)
while (n > 0)
n -= 1
i = i << 8
i = i | s[n] # yep, a 1 char slice in an integer context is guess what?
end
fh.close()
return i
end
And finally, to put it all together, here's a couple of tests:
% ruby -r profile -e 'require "modexp.rb"' -e "10.times do a=128.random ;
a.gcdb(128.random) ; end"
% cumulative self self total
time seconds seconds calls ms/call ms/call name
55.18 8.09 8.09 10 809.00 1271.00 Crypto_math.gcdb
9.00 9.41 1.32 20 66.00 97.00 Crypto_math.random
6.62 10.38 0.97 20902 0.05 0.05 Bignum#[]
6.48 11.33 0.95 21744 0.04 0.04 Fixnum#==
5.05 12.07 0.74 13853 0.05 0.05 Bignum#>>
4.50 12.73 0.66 7025 0.09 0.14 Comparable.>
2.52 13.10 0.37 7035 0.05 0.05 Bignum#-
2.46 13.46 0.36 7038 0.05 0.05 Bignum#==
2.18 13.78 0.32 7035 0.05 0.05 Bignum#<=>
1.23 13.96 0.18 2765 0.07 0.07 Fixnum#-
1.16 14.13 0.17 2474 0.07 0.07 Bignum#<<
1.09 14.29 0.16 3512 0.05 0.05 Bignum#-@
0.68 14.39 0.10 2494 0.04 0.04 Bignum#|
0.61 14.48 0.09 2791 0.03 0.03 Fixnum#>
0.41 14.54 0.06 423 0.14 0.14 Fixnum#>>
0.41 14.60 0.06 2560 0.02 0.02 String#[]
0.14 14.62 0.02 634 0.03 0.03 Fixnum#[]
0.07 14.63 0.01 66 0.15 0.15 Fixnum#|
0.07 14.64 0.01 1 10.00 10.00 Kernel.require
0.07 14.65 0.01 40 0.25 0.25 Numeric#clone
0.07 14.66 0.01 118 0.08 0.08 Fixnum#-@
0.00 14.66 0.00 10 0.00 0.00 Fixnum#*
0.00 14.66 0.00 20 0.00 0.00 Kernel.open
0.00 14.66 0.00 10 0.00 0.00 Module#method_added
0.00 14.66 0.00 2 0.00 0.00 Module#append_features
0.00 14.66 0.00 1 0.00 14650.00 Fixnum#times
0.00 14.66 0.00 10 0.00 0.00 Comparable.>=
0.00 14.66 0.00 4 0.00 0.00 Bignum#coerce
0.00 14.66 0.00 20 0.00 0.00 IO#close
0.00 14.66 0.00 96 0.00 0.00 Fixnum#<<
0.00 14.66 0.00 1 0.00 0.00 Class#inherited
0.00 14.66 0.00 3 0.00 0.00 Fixnum#+
0.00 14.66 0.00 20 0.00 0.00 IO#read
0.00 14.66 0.00 2 0.00 0.00 Module#include
0.00 14.66 0.00 1 0.00 14660.00 #toplevel
% ruby -r profile -e 'require "modexp.rb"' -e "10.times do a=128.random ;
a.gcd(128.random) ; end"
% cumulative self self total
time seconds seconds calls ms/call ms/call name
37.34 2.39 2.39 10 239.00 439.00 Crypto_math.gcd
21.72 3.78 1.39 20 69.50 99.50 Crypto_math.random
12.97 4.61 0.83 5875 0.14 0.18 Comparable.>
9.53 5.22 0.61 12182 0.05 0.05 Numeric#clone
4.53 5.51 0.29 5885 0.05 0.05 Bignum#%
4.06 5.77 0.26 5885 0.04 0.04 Bignum#<=>
2.97 5.96 0.19 2493 0.08 0.08 Bignum#|
2.50 6.12 0.16 2473 0.06 0.06 Bignum#<<
1.87 6.24 0.12 2560 0.05 0.05 Fixnum#-
1.25 6.32 0.08 2560 0.03 0.03 String#[]
0.47 6.35 0.03 2786 0.01 0.01 Fixnum#>
0.16 6.36 0.01 1 10.00 6390.00 Fixnum#times
0.16 6.37 0.01 67 0.15 0.15 Fixnum#|
0.16 6.38 0.01 1 10.00 10.00 Kernel.require
0.16 6.39 0.01 87 0.11 0.11 Fixnum#<<
0.16 6.40 0.01 186 0.05 0.05 Fixnum#%
0.00 6.40 0.00 2 0.00 0.00 Module#append_features
0.00 6.40 0.00 10 0.00 0.00 Module#method_added
0.00 6.40 0.00 20 0.00 0.00 IO#close
0.00 6.40 0.00 10 0.00 1.00 Comparable.>=
0.00 6.40 0.00 20 0.00 0.00 Kernel.open
0.00 6.40 0.00 1 0.00 0.00 Class#inherited
0.00 6.40 0.00 20 0.00 0.00 IO#read
0.00 6.40 0.00 2 0.00 0.00 Module#include
0.00 6.40 0.00 1 0.00 6400.00 #toplevel
As you can see, the gcd routine is very much faster than the gcdb
routine, by a large amount (as in, gcdb is only 2/3rds the speed). I
did without -r profile and used Unix 'time' command and got same
result, gcdb only 2/3rds the speed of gcd for 128-byte (1024-bit)
Bignums. The problem appears to be the number of a[0]=0 type calls
Stein's algorithm, note the big # of calls to [] and to ==.
Right now, it appears to me that the only way to speed up things is to
write a 'even-ness' test in "C" that looks at the lower-order bit and
goes from there, without doing all the array computations and etc.
Otherwise 'gcd' will always be faster, because it does not have the
20,000 calls to [] and == that are boggind down gcdb with procedure
call overhead. A 'iseven?' call will halve the number of calls
immediately by eliminating the == part (since I can return a boolean
and use the boolean directly in computations). That will not however
make it faster. If you look, next up comes the swap overhead (the test
and swap part of "while t != 0" which Ruby turns into bignum
comparison of t > 0, the negating of bignums, and the right shifting
of bignums. The overhead of doing all these on 1024-bit numbers
appears to be heavier than the overhead of doing a simple % on
1024-bit numbers, and it appears that I will need to go to "C" if I
need to have anything faster than the plain old Euclidean GCD in
Ruby. (BTW, I sped up the Euclidean gcd even more by removing the
..clone calls from the inner loop, they were not needed since nothing
modified the values in place).
Eric Lee Green Web: http://www.badtux.org
GnuPG public key at http://badtux.org/eric/eric.gpg
Free Dmitry Sklyarov! [ http://www.eff.org ]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE7a38j3DrrK1kMA04RAisbAJwIYrH/Y+41eY36+CPkYp3mQyhpZACfYNFb
K2/gihnWQPOtO12HrvVsstE=
=1J3h
-----END PGP SIGNATURE-----