Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6505039d7214
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8a846d370eec
Choose a head ref
  • 4 commits
  • 3 files changed
  • 1 contributor

Commits on Feb 9, 2016

  1. Copy the full SHA
    0ebac26 View commit details
  2. Copy the full SHA
    a225970 View commit details
  3. Copy the full SHA
    3a9d48f View commit details
  4. Copy the full SHA
    8a846d3 View commit details
Showing with 173 additions and 6 deletions.
  1. +21 −0 test/truffle/metrics/codeload.rb
  2. +104 −0 test/truffle/metrics/mandelbrot.rb
  3. +48 −6 tool/jt.rb
21 changes: 21 additions & 0 deletions test/truffle/metrics/codeload.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
10_000.times do |n|
eval %{
def foo#{n}(a, b, c)
if a == b
a + b + c # comments
else
a.foo + b.foo + c.foo
end
end
class Foo#{n}
def bar#{n}
[#{n}, #{n} + 1, #{n} + 2]
end
def baz#{n}
{a: #{n}, b: #{n + 1}, c: #{n + 2}}
end
end
}
end
104 changes: 104 additions & 0 deletions test/truffle/metrics/mandelbrot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Copyright © 2004-2013 Brent Fulgham
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of "The Computer Language Benchmarks Game" nor the name
# of "The Computer Language Shootout Benchmarks" nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# The Computer Language Benchmarks Game
# http://benchmarksgame.alioth.debian.org
#
# contributed by Karl von Laudermann
# modified by Jeremy Echols
# modified by Detlef Reichl
# modified by Joseph LaFata
# modified by Peter Zotov

# http://benchmarksgame.alioth.debian.org/u64q/program.php?test=mandelbrot&lang=yarv&id=3

def mandelbrot(size)
sum = 0

byte_acc = 0
bit_num = 0

y = 0
while y < size
ci = (2.0*y/size)-1.0

x = 0
while x < size
zrzr = zr = 0.0
zizi = zi = 0.0
cr = (2.0*x/size)-1.5
escape = 0b1

z = 0
while z < 50
tr = zrzr - zizi + cr
ti = 2.0*zr*zi + ci
zr = tr
zi = ti
# preserve recalculation
zrzr = zr*zr
zizi = zi*zi
if zrzr+zizi > 4.0
escape = 0b0
break
end
z += 1
end

byte_acc = (byte_acc << 1) | escape
bit_num += 1

# Code is very similar for these cases, but using separate blocks
# ensures we skip the shifting when it's unnecessary, which is most cases.
if (bit_num == 8)
#print byte_acc.chr
sum ^= byte_acc
byte_acc = 0
bit_num = 0
elsif (x == size - 1)
byte_acc <<= (8 - bit_num)
#print byte_acc.chr
sum ^= byte_acc
byte_acc = 0
bit_num = 0
end
x += 1
end
y += 1
end

sum
end

start = Time.now

while Time.now - start < 30
mandelbrot(25)
end
54 changes: 48 additions & 6 deletions tool/jt.rb
Original file line number Diff line number Diff line change
@@ -148,10 +148,21 @@ def raw_sh(*args)
else
puts "$ #{printable_cmd(args)}"
end
continue_on_failure = false
if args.last == :continue_on_failure
args.pop
continue_on_failure = true
end
result = system(*args)
unless result
$stderr.puts "FAILED (#{$?}): #{printable_cmd(args)}"
exit $?.exitstatus
if result
true
else
if continue_on_failure
false
else
$stderr.puts "FAILED (#{$?}): #{printable_cmd(args)}"
exit $?.exitstatus
end
end
end

@@ -250,7 +261,8 @@ def help
puts 'jt bench compare [benchmarks] run a set of benchmarks and compare against a reference point'
puts ' benchmarks can be any benchmarks or group of benchmarks supported'
puts ' by bench9000, eg all, classic, chunky, 3, 5, 10, 15 - default is 5'
puts 'jt metrics alloc ... how much memory is allocated running a program (use -X-T to test normal JRuby)'
puts 'jt metrics alloc ... how much memory is allocated running a program (use -X-T to test normal JRuby on this metric and others)'
puts 'jt metrics minheap ... what is the smallest heap you can use to run an application'
puts 'jt metrics time ... how long does it take to run a command, broken down into different phases'
puts 'jt install ..../graal/mx/suite.py install a JRuby distribution into an mx suite'
puts
@@ -550,6 +562,8 @@ def metrics(command, *args)
case command
when 'alloc'
metrics_alloc *args
when 'minheap'
metrics_minheap *args
when 'time'
metrics_time *args
else
@@ -587,6 +601,30 @@ def memory_allocated(trace)
allocated
end

def metrics_minheap(*args)
# Why aren't you doing a binary search? The results seem pretty noisy so
# unless you do reps at each level I'm not sure how to make it work
# reliably.
heap = 1
successful = 0
loop do
if successful > 0
print '?' if STDOUT.tty?
else
print '+' if STDOUT.tty?
end
if run("-J-Xmx#{heap}M", *args, {err: '/dev/null', out: '/dev/null'}, :continue_on_failure, :no_print_cmd)
successful += 1
break if successful == METRICS_REPS
else
heap += 1
successful = 0
end
end
puts if STDOUT.tty?
puts "#{heap} MB"
end

def metrics_time(*args)
samples = []
METRICS_REPS.times do
@@ -637,10 +675,14 @@ def get_times(trace, total)
def human_size(bytes)
if bytes < 1024
"#{bytes} B"
elsif bytes < 1024**2
elsif bytes < 1000**2
"#{(bytes/1024.0).round(2)} KB"
else
elsif bytes < 1000**3
"#{(bytes/1024.0**2).round(2)} MB"
elsif bytes < 1000**4
"#{(bytes/1024.0**3).round(2)} GB"
else
"#{(bytes/1024.0**4).round(2)} TB"
end
end