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
5002.732.757,508326  1% 2% 0% 100%
3,000101.24101.278,424326  0% 0% 0% 100%
5,500344.69344.789,504326  0% 1% 0% 100%

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

Read spectral-norm benchmark to see what this program should do.

 notes

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

 spectral-norm Ruby #4 program source code

# The Computer Language Benchmarks Game
# http://benchmarksgame.alioth.debian.org
# Contributed by Sokolov Yura
# Modified by Chris Houhoulis (April 2013):
#   - made loops uglier to avoid the unnecessary overhead of blocks
#   - nicer naming for readability



ARRAY_LENGTH = ARGV[0].to_i

u = Array.new(ARRAY_LENGTH, 1)
v = []

def eval_A(i,j)
  1.0/((i+j)*(i+j+1)/2+i+1)
end

def vector_times_array(vector)
  arr, i = [], 0
  while i < ARRAY_LENGTH
    sum, j = 0, 0
    while j < ARRAY_LENGTH
      sum += eval_A(i,j) * vector[j]
      j += 1
    end
    arr << sum
    i += 1
  end
  arr
end

def vector_times_array_transposed(vector)
  arr, i = [], 0
  while i < ARRAY_LENGTH
    sum, j = 0, 0
    while j < ARRAY_LENGTH
      sum += eval_A(j,i) * vector[j]
      j += 1
    end
    arr << sum
    i += 1
  end
  arr
end

def vector_times_array_times_array_transposed(vector)
  vector_times_array_transposed(vector_times_array(vector))
end

10.times do
  v = vector_times_array_times_array_transposed(u)
  u = vector_times_array_times_array_transposed(v)
end

vBv, vv, i = 0, 0, 0
while i < ARRAY_LENGTH
  vBv += u[i]*v[i]
  vv += v[i]*v[i]
  i += 1
end

print "%0.9f" % (Math.sqrt(vBv/vv)), "\n"

 make, command-line, and program output logs

Thu, 09 Jan 2014 09:38:46 GMT

COMMAND LINE:
/usr/local/src/ruby-2.1.0/ruby spectralnorm.yarv-4.yarv 5500

PROGRAM OUTPUT:
1.274224153

Revised BSD license

  Home   Conclusions   License   Play