Sha256: a181364701d74bed5fb1508bff54ef5ee5d39d301aa2dda12614a4bb52c9756a

Contents?: true

Size: 502 Bytes

Versions: 9

Compression:

Stored size: 502 Bytes

Contents

require 'prime3'

# Need to use wall time for this test due to the sleep calls
RubyProf::measure_mode = RubyProf::WALL_TIME

def find_primes(arr)
  result = arr.select do |value|
    is_prime(value)
  end
  result
end

def find_largest(primes)
  largest = primes.first

  # Intentionally use upto for example purposes
  # (upto is also called from is_prime)
  0.upto(primes.length-1) do |i|
    sleep(0.02)
    prime = primes[i]
    if prime > largest
      largest = prime
    end
  end
  largest
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
jeremy-ruby-prof-0.6.1 test/prime2.rb
ruby-prof-0.5.2-mswin32 test/prime2.rb
ruby-prof-0.5.1-mswin32 test/prime2.rb
ruby-prof-0.5.0-mswin32 test/prime2.rb
ruby-prof-0.5.1 test/prime2.rb
ruby-prof-0.6.0 test/prime2.rb
ruby-prof-0.6.0-x86-mswin32-60 test/prime2.rb
ruby-prof-0.5.2 test/prime2.rb
ruby-prof-0.5.0 test/prime2.rb