[#5322] O(1) performance for insertions/deletions at the front of an Array/String — Eric Mahurin <eric_mahurin@...>

I just did some benchmarks on push, pop, shift, and unshift

24 messages 2005/07/01
[#5338] Re: O(1) performance for insertions/deletions at the front of an Array/String — Mathieu Bouchard <matju@...> 2005/07/02

On Fri, 1 Jul 2005, Eric Mahurin wrote:

[#5348] Re: O(1) performance for insertions/deletions at the front of an Array/String — Eric Mahurin <eric_mahurin@...> 2005/07/02

--- Mathieu Bouchard <matju@artengine.ca> wrote:

[#5357] Re: O(1) performance for insertions/deletions at the front of an Array/String — Mathieu Bouchard <matju@...> 2005/07/03

On Sat, 2 Jul 2005, Eric Mahurin wrote:

[#5359] Re: O(1) performance for insertions/deletions at the front of an Array/String — Eric Mahurin <eric_mahurin@...> 2005/07/03

--- Mathieu Bouchard <matju@artengine.ca> wrote:

[#5361] Re: O(1) performance for insertions/deletions at the front of an Array/String — Mathieu Bouchard <matju@...> 2005/07/03

On Sun, 3 Jul 2005, Eric Mahurin wrote:

[#5362] Re: O(1) performance for insertions/deletions at the front of an Array/String — Eric Mahurin <eric_mahurin@...> 2005/07/03

--- Mathieu Bouchard <matju@artengine.ca> wrote:

[#5365] Re: O(1) performance for insertions/deletions at the front of an Array/String — Yukihiro Matsumoto <matz@...> 2005/07/04

Hi,

[#5367] Re: O(1) performance for insertions/deletions at the front of an Array/String — Eric Mahurin <eric_mahurin@...> 2005/07/04

--- Yukihiro Matsumoto <matz@ruby-lang.org> wrote:

[#5368] Re: O(1) performance for insertions/deletions at the front of an Array/String — Yukihiro Matsumoto <matz@...> 2005/07/04

Hi,

[#5372] Re: O(1) performance for insertions/deletions at the front of an Array/String — Florian Gro<florgro@...> 2005/07/04

Yukihiro Matsumoto wrote:

[#5420] Sydney Developer Preview 1 released — Evan Webb <evanwebb@...>

Sydney, an experimental ruby interpreter, has been released!

15 messages 2005/07/11
[#5424] Re: [ANN] Sydney Developer Preview 1 released — Evan Webb <evanwebb@...> 2005/07/12

Thanks everyone for the feedback so far!

Possible Bug in Documentation or implementation of srand

From: Charles Comstock <dgtized@...>
Date: 2005-07-08 12:27:31 UTC
List: ruby-core #5415
According to documentation srand of 0 is supposed to reset srand to
some random value from the clock and whatnot.  Unfortuneatly this only
actually occurs if you call srand with no argument.   See example
below:

irb(main):001:0> srand 0
=> 0
irb(main):002:0> rand
=> 0.548813503927325
irb(main):003:0> rand
=> 0.715189366372419
irb(main):004:0> srand 0
=> 0
irb(main):005:0> rand
=> 0.548813503927325
irb(main):006:0> rand
=> 0.715189366372419
irb(main):007:0> srand
=> 0
irb(main):008:0> rand
=> 0.0934072350449292
irb(main):009:0>

Here is the apparently documentation that seems to be mistaken from my
interpretation

----------------------------------------------------------- Kernel#srand
     srand(number=0)    => old_seed
------------------------------------------------------------------------
     Seeds the pseudorandom number generator to the value of
     _number_.+to_i.abs+. If _number_ is omitted or zero, seeds the
     generator using a combination of the time, the process id, and a
     sequence number. (This is also the behavior if +Kernel::rand+ is
     called without previously calling +srand+, but without the
     sequence.) By setting the seed to a known value, scripts can be
     made deterministic during testing. The previous seed value is
     returned. Also see +Kernel::rand+.

It's possible that I may misinterpreting something in this description
but it seems like the line "If _number is omitted or zero, seeds the
generator" is not happening as exhibited in my above example.

Can anyone shed any light on this behavior?  Is the code incorrect or
is the documentation incorrect?

Charles Comstock


In This Thread

Prev Next