performance measurements

Each table row shows performance measurements for this Ruby program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
500,0002.662.6615,580331  0% 0% 1% 100%
5,000,00025.7325.7515,580331  1% 1% 1% 100%
50,000,000259.66259.8015,576331  0% 1% 1% 100%

Read the ↓ make, command line, and program output logs to see how this program was run.

Read thread-ring benchmark to see what this program should do.

 notes

ruby 2.1.0p0 (2013-12-25 revision 44422) [i686-linux]

 thread-ring Ruby program source code

# The Computer Language Benchmarks Game
# http://benchmarksgame.alioth.debian.org
# contributed by Klaus Friedel
#

#require "thread"

THREAD_COUNT = 503

class Receiver
  @next
  @mailbox

  def initialize(name)
    @name = name
    @mailbox = Queue.new
  end

  def next=(n)
    @next = n
  end

  def put(msg)
    @mailbox.push(msg)
  end

  def messageloop
    while true
      hopsRemaining = @mailbox.pop
      if(hopsRemaining == 0)
        print @name, "\n"
        exit(0)
      end
      @next.put(hopsRemaining - 1)
    end
  end
end

##########
#  Main  #
##########
receivers = []
for i in 0..THREAD_COUNT-1
  receivers[i] = Receiver.new(i+1)
  if(i > 0)
    receivers[i-1].next = receivers[i]
  end
end
#close the ring
receivers[THREAD_COUNT-1].next = receivers[0]

# start the threads
for i in 0..THREAD_COUNT-1
  Thread.start(i){|k| receivers[k].messageloop}
end

receivers[0].put(ARGV[0].to_i)

sleep

 make, command-line, and program output logs

Wed, 08 Jan 2014 13:30:19 GMT

COMMAND LINE:
/usr/local/src/ruby-2.1.0/ruby threadring.yarv 50000000

PROGRAM OUTPUT:
292

Revised BSD license

  Home   Conclusions   License   Play