In Files

  • benchmark/bm_ao_render.rb
  • benchmark/bm_app_lc_fizzbuzz.rb
  • benchmark/bm_fib.rb
  • benchmark/bm_so_lists.rb
  • examples/targets/build_config_ArduinoDue.rb
  • examples/targets/build_config_IntelEdison.rb
  • examples/targets/build_config_IntelGalileo.rb
  • examples/targets/build_config_RX630.rb
  • examples/targets/build_config_chipKITMax32.rb
  • minirake
  • mrbgems/mruby-array-ext/test/array.rb
  • mrbgems/mruby-bin-debugger/bintest/mrdb.rb
  • mrbgems/mruby-bin-mruby/bintest/mruby.rb
  • mrbgems/mruby-class-ext/test/module.rb
  • mrbgems/mruby-complex/test/complex.rb
  • mrbgems/mruby-enum-ext/test/enum.rb
  • mrbgems/mruby-enumerator/test/enumerator.rb
  • mrbgems/mruby-eval/test/eval.rb
  • mrbgems/mruby-io/mrblib/io.rb
  • mrbgems/mruby-io/test/io.rb
  • mrbgems/mruby-kernel-ext/test/kernel.rb
  • mrbgems/mruby-math/test/math.rb
  • mrbgems/mruby-metaprog/test/metaprog.rb
  • mrbgems/mruby-method/test/method.rb
  • mrbgems/mruby-object-ext/test/object.rb
  • mrbgems/mruby-pack/test/pack.rb
  • mrbgems/mruby-proc-ext/test/proc.rb
  • mrbgems/mruby-rational/test/rational.rb
  • mrbgems/mruby-socket/test/unix.rb
  • mrbgems/mruby-string-ext/test/string.rb
  • mrbgems/mruby-struct/test/struct.rb
  • mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb
  • mrbgems/mruby-toplevel-ext/test/toplevel.rb

Object

Constants

ARDUINO_PATH

Mac OS X, Arduino IDE <= 1.5.6 ARDUINO_PATH = '/Applications/Arduino.app/Contents/Resources/Java' Mac OS X, Arduino IDE >= 1.5.7 ARDUINO_PATH = '/Applications/Arduino.app/Contents/Java' GNU Linux

BIN_PATH

Arduino IDE <= 1.5.6

FIRST
GALILEO_ARDUINO_PATH

Mac OS X Assume you renamed Arduino.app to Arduino_Galileo.app

GALILEO_BIN_PATH
GNU Linux

ARDUINO_GALILEO_PATH = '/opt/arduino'

GALILEO_SYSROOT
GALILEO_X86_PATH
IF
IMAGE_HEIGHT
IMAGE_WIDTH

AO render benchmark Original program (C) Syoyo Fujita in Javascript (and other languages)

https://code.google.com/p/aobench/

Ruby(yarv2llvm) version by Hideki Miura mruby version by Hideki Miura

INVCMD
IS_EMPTY
LEFT
MPIDE_PATH

Mac OS X MPIDE_PATH = '/Applications/Mpide.app/Contents/Resources/Java' GNU Linux

N
NAO_SAMPLES
NSUBSAMPLES
NUM

from www.bagley.org/~doug/shootout/bench/lists/lists.ruby

PACK_IS_LITTLE_ENDIAN
PIC32_PATH
POKY_EDISON_BIN_PATH
POKY_EDISON_PATH

Mac OS X

POKY_EDISON_SYSROOT
POKY_EDISON_X86_PATH
REST
RIGHT
Rake
SAM_PATH

Arduino IDE >= 1.5.7 BIN_PATH = “#{ARDUINO_PATH}/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin”

SIZE
STDERR
STDIN
STDOUT
Struct
TARGET_PATH
UTF8STRING

String(Ext) Test

Public Class Methods

bar() click to toggle source
 
               # File mrbgems/mruby-method/test/method.rb, line 230
def self.bar; end
            
foo() click to toggle source
 
               # File mrbgems/mruby-method/test/method.rb, line 435
def foo
end
            
include(*modules) click to toggle source
 
               # File mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb, line 2
def self.include (*modules)
  self.class.include(*modules)
end
            
new() click to toggle source
 
               # File mrbgems/mruby-method/test/method.rb, line 37
def initialize; @done = false; end
            
private(*methods) click to toggle source
 
               # File mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb, line 6
def self.private(*methods)
end
            
protected(*methods) click to toggle source
 
               # File mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb, line 8
def self.protected(*methods)
end
            
public(*methods) click to toggle source
 
               # File mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb, line 10
def self.public(*methods)
end
            

Public Instance Methods

assert_cmp(exp, o1, o2) click to toggle source
 
               # File mrbgems/mruby-rational/test/rational.rb, line 44
def assert_cmp(exp, o1, o2)
  if exp == (o1 <=> o2)
    pass
  else
    flunk "", "    Expected #{o1.inspect} <=> #{o2.inspect} to be #{exp}."
  end
end
            
assert_combination(exp, receiver, *args) click to toggle source
 
               # File mrbgems/mruby-array-ext/test/array.rb, line 17
def assert_combination(exp, receiver, *args)
  assert_permutation_combination(exp, receiver, :combination, *args)
end
            
assert_complex(real, exp) click to toggle source
 
               # File mrbgems/mruby-complex/test/complex.rb, line 1
def assert_complex(real, exp)
  assert "assert_complex" do
    assert_float real.real,      exp.real
    assert_float real.imaginary, exp.imaginary
  end
end
            
assert_equal_rational(exp, o1, o2) click to toggle source
 
               # File mrbgems/mruby-rational/test/rational.rb, line 32
def assert_equal_rational(exp, o1, o2)
  assert "assert_equal_rational" do
    if exp
      assert_operator(o1, :==, o2)
      assert_not_operator(o1, :!=, o2)
    else
      assert_not_operator(o1, :==, o2)
      assert_operator(o1, :!=, o2)
    end
  end
end
            
assert_io_open(meth) click to toggle source
 
               # File mrbgems/mruby-io/test/io.rb, line 7
def assert_io_open(meth)
  assert "assert_io_open" do
    fd = IO.sysopen($mrbtest_io_rfname)
    assert_equal Fixnum, fd.class
    io1 = IO.__send__(meth, fd)
    begin
      assert_equal IO, io1.class
      assert_equal $mrbtest_io_msg, io1.read
    ensure
      io1.close
    end

    io2 = IO.__send__(meth, IO.sysopen($mrbtest_io_rfname))do |io|
      if meth == :open
        assert_equal $mrbtest_io_msg, io.read
      else
        flunk "IO.#{meth} does not take block"
      end
    end
    io2.close unless meth == :open
  end
end
            
assert_mruby(exp_out, exp_err, exp_success, args) click to toggle source
 
               # File mrbgems/mruby-bin-mruby/bintest/mruby.rb, line 4
def assert_mruby(exp_out, exp_err, exp_success, args)
  out, err, stat = Open3.capture3(cmd("mruby"), *args)
  assert "assert_mruby" do
    assert_operator(exp_out, :===, out, "standard output")
    assert_operator(exp_err, :===, err, "standard error")
    assert_equal(exp_success, stat.success?, "exit success?")
  end
end
            
assert_pack(tmpl, packed, unpacked) click to toggle source
 
               # File mrbgems/mruby-pack/test/pack.rb, line 3
def assert_pack tmpl, packed, unpacked
  t = tmpl.inspect
  assert "assert_pack" do
    assert_equal packed, unpacked.pack(tmpl), "#{unpacked.inspect}.pack(#{t})"
    assert_equal unpacked, packed.unpack(tmpl), "#{packed.inspect}.unpack(#{t})"
  end
end
            
assert_permutation(exp, receiver, *args) click to toggle source
 
               # File mrbgems/mruby-array-ext/test/array.rb, line 13
def assert_permutation(exp, receiver, *args)
  assert_permutation_combination(exp, receiver, :permutation, *args)
end
            
assert_permutation_combination(exp, receiver, meth, *args) click to toggle source

Array(Ext) Test

 
               # File mrbgems/mruby-array-ext/test/array.rb, line 4
def assert_permutation_combination(exp, receiver, meth, *args)
  act = []
  ret = receiver.__send__(meth, *args) { |v| act << v }
  assert "assert_#{meth}" do
    assert_equal(exp, act.sort)
    assert_same(receiver, ret)
  end
end
            
assert_rational(exp, real) click to toggle source
 
               # File mrbgems/mruby-rational/test/rational.rb, line 25
def assert_rational(exp, real)
  assert "assert_rational" do
    assert_float exp.numerator,   real.numerator
    assert_float exp.denominator, real.denominator
  end
end
            
assert_take(exp, enumerator) click to toggle source
 
               # File mrbgems/mruby-enumerator/test/enumerator.rb, line 9
def assert_take(exp, enumerator)
  result = []
  n = exp.size
  enumerator.each do |v|
    result << v
    n -= 1
    break if n == 0
  end if n > 0
  assert_equal exp, result
end
            
assert_upto(exp, receiver, *args) click to toggle source
 
               # File mrbgems/mruby-string-ext/test/string.rb, line 6
def assert_upto(exp, receiver, *args)
  act = []
  receiver.upto(*args) { |v| act << v }
  assert_equal exp, act
end
            
bar(x) click to toggle source
 
               # File mrbgems/mruby-eval/test/eval.rb, line 105
def bar(x)
  instance_eval "def baz; #{x}; end"
end
            
baz(*args) click to toggle source
 
               # File mrbgems/mruby-kernel-ext/test/kernel.rb, line 19
def baz(*args)
  bar(*args)
end
            
between(lo, x, hi) click to toggle source
 
               # File mrbgems/mruby-array-ext/test/array.rb, line 268
def between(lo, x, hi)
  if x < lo
    1
  elsif x > hi
    -1
  else
    0
  end
end
            
clamp(f) click to toggle source
 
               # File benchmark/bm_ao_render.rb, line 171
def clamp(f)
  i = f * 255.5
  if i > 255.0
    i = 255.0
  end
  if i < 0.0
    i = 0.0
  end
  i.to_i
end
            
do_eval(code) click to toggle source
 
               # File mrbgems/mruby-eval/test/eval.rb, line 124
def do_eval(code)
  eval(code)
end
            
each() click to toggle source
 
               # File mrbgems/mruby-enum-ext/test/enum.rb, line 150
def each
end
            
enable_debug_info?() click to toggle source

Proc(Ext) Test

 
               # File mrbgems/mruby-proc-ext/test/proc.rb, line 4
def enable_debug_info?
  return @enable_debug_info unless @enable_debug_info == nil
  begin
    raise
  rescue => e
    @enable_debug_info = !e.backtrace.empty?
  end
end
            
fib(n) click to toggle source
 
               # File benchmark/bm_fib.rb, line 2
def fib n
  return n if n < 2
  fib(n-2) + fib(n-1)
end
            
foo(*args) click to toggle source
 
               # File mrbgems/mruby-kernel-ext/test/kernel.rb, line 11
def foo(*args)
  caller(*args)
end
            
hello() click to toggle source
 
               # File mrbgems/mruby-class-ext/test/module.rb, line 102
def hello
  "hello"
end
            
hi() click to toggle source
 
               # File mrbgems/mruby-class-ext/test/module.rb, line 94
def hi
  "hi"
end
            
labeled_class(name, supklass = Object, &block) click to toggle source
 
               # File mrbgems/mruby-metaprog/test/metaprog.rb, line 156
def labeled_class(name, supklass = Object, &block)
  Class.new(supklass) do
    (class <<self; self end).class_eval do
      define_method(:to_s) { name }
      alias_method :inspect, :to_s
    end
    class_eval(&block) if block
  end
end
            
labeled_module(name, &block) click to toggle source
 
               # File mrbgems/mruby-metaprog/test/metaprog.rb, line 146
def labeled_module(name, &block)
  Module.new do
    (class <<self; self end).class_eval do
      define_method(:to_s) { name }
      alias_method :inspect, :to_s
    end
    class_eval(&block) if block
  end
end
            
m() click to toggle source
 
               # File mrbgems/mruby-kernel-ext/test/kernel.rb, line 38
def m; __method__; end
            
m0() click to toggle source
 
               # File mrbgems/mruby-method/test/method.rb, line 38
def m0() end
            
m1() click to toggle source
 
               # File mrbgems/mruby-metaprog/test/metaprog.rb, line 274
def m1; end
            
m2() click to toggle source
 
               # File mrbgems/mruby-metaprog/test/metaprog.rb, line 275
def m2;end
            
ma1((a), &b) click to toggle source
 
               # File mrbgems/mruby-method/test/method.rb, line 48
def ma1((a), &b) nil && a end
            
meth() click to toggle source
 
               # File mrbgems/mruby-method/test/method.rb, line 424
def meth() :meth end
            
method_missing(m, *argv) click to toggle source
 
               # File mrbgems/mruby-method/test/method.rb, line 115
def method_missing(m, *argv)
  @m = m
  @argv = argv
  super
end
            
mo1(a = nil, &b) click to toggle source
 
               # File mrbgems/mruby-method/test/method.rb, line 41
def mo1(a = nil, &b) end
            
mo2(a, b = nil) click to toggle source
 
               # File mrbgems/mruby-method/test/method.rb, line 42
def mo2(a, b = nil) end
            
mo3(*a) click to toggle source
 
               # File mrbgems/mruby-method/test/method.rb, line 43
def mo3(*a) end
            
mo4(a, *b, &c) click to toggle source
 
               # File mrbgems/mruby-method/test/method.rb, line 44
def mo4(a, *b, &c) end
            
mo5(a, *b, c) click to toggle source
 
               # File mrbgems/mruby-method/test/method.rb, line 45
def mo5(a, *b, c) end
            
mo6(a, *b, c, &d) click to toggle source
 
               # File mrbgems/mruby-method/test/method.rb, line 46
def mo6(a, *b, c, &d) end
            
mo7(a, b = nil, *c, d, &e) click to toggle source
 
               # File mrbgems/mruby-method/test/method.rb, line 47
def mo7(a, b = nil, *c, d, &e) end
            
otherBasis(basis, n) click to toggle source
 
               # File benchmark/bm_ao_render.rb, line 182
def otherBasis(basis, n)
  basis[2] = Vec.new(n.x, n.y, n.z)
  basis[1] = Vec.new(0.0, 0.0, 0.0)

  if n.x < 0.6 and n.x > -0.6
    basis[1].x = 1.0
  elsif n.y < 0.6 and n.y > -0.6
    basis[1].y = 1.0
  elsif n.z < 0.6 and n.z > -0.6
    basis[1].z = 1.0
  else
    basis[1].x = 1.0
  end

  basis[0] = basis[1].vcross(basis[2])
  basis[0] = basis[0].vnormalize

  basis[1] = basis[2].vcross(basis[0])
  basis[1] = basis[1].vnormalize
end
            
respond_to_missing?(m, b) click to toggle source
 
               # File mrbgems/mruby-method/test/method.rb, line 67
def respond_to_missing?(m, b)
  m == :nothing
end
            
run() click to toggle source
 
               # File mrbgems/mruby-method/test/method.rb, line 50
def run
  assert_equal(0, method(:m0).arity)
  assert_equal(1, method(:m1).arity)
  assert_equal(2, method(:m2).arity)
  assert_equal(-1, method(:mo1).arity)
  assert_equal(-2, method(:mo2).arity)
  assert_equal(-1, method(:mo3).arity)
  assert_equal(-2, method(:mo4).arity)
  assert_equal(-3, method(:mo5).arity)
  assert_equal(-3, method(:mo6).arity)
  assert_equal(-3, method(:mo7).arity)
  assert_equal(1, method(:ma1).arity)

  assert_equal(-1, method(:__send__).arity)
  assert_equal(-1, method(:nothing).arity)
end
            
test_lists() click to toggle source
 
               # File benchmark/bm_so_lists.rb, line 6
def test_lists()
  # create a list of integers (Li1) from 1 to SIZE
  li1 = (1..SIZE).to_a
  # copy the list to li2 (not by individual items)
  li2 = li1.dup
  # remove each individual item from left side of li2 and
  # append to right side of li3 (preserving order)
  li3 = Array.new
  while (not li2.empty?)
    li3.push(li2.shift)
  end
  # li2 must now be empty
  # remove each individual item from right side of li3 and
  # append to right side of li2 (reversing list)
  until li3.empty?
    li2.push(li3.pop)
  end
  # li3 must now be empty
  # reverse li1 in place
  li1.reverse!
  # check that first item is now SIZE
  if li1[0] != SIZE
    p "not SIZE"
    0
  else
    # compare li1 and li2 for equality
    if li1 != li2
      return(0)
    else
      # return the length of the list
      li1.length
    end
  end
end
            
to_array(proc) click to toggle source
 
               # File benchmark/bm_app_lc_fizzbuzz.rb, line 28
def to_array(proc)
  array = []

  until to_boolean(IS_EMPTY[proc])
    array.push(FIRST[proc])
    proc = REST[proc]
  end

  array
end
            
to_boolean(proc) click to toggle source
 
               # File benchmark/bm_app_lc_fizzbuzz.rb, line 24
def to_boolean(proc)
  IF[proc][true][false]
end
            
to_char(c) click to toggle source
 
               # File benchmark/bm_app_lc_fizzbuzz.rb, line 39
def to_char(c)
  '0123456789BFiuz'.slice(to_integer(c))
end
            
to_integer(proc) click to toggle source
 
               # File benchmark/bm_app_lc_fizzbuzz.rb, line 20
def to_integer(proc)
  proc[-> n { n + 1 }][0]
end
            
to_string(s) click to toggle source
 
               # File benchmark/bm_app_lc_fizzbuzz.rb, line 43
def to_string(s)
  to_array(s).map { |c| to_char(c) }.join
end
            
unixserver_test_block() click to toggle source
 
               # File mrbgems/mruby-socket/test/unix.rb, line 3
def unixserver_test_block
  path = SocketTest.tmppath
  File.unlink path rescue nil
  begin
    result = yield path
  ensure
    File.unlink path rescue nil
  end
  result
end
            
with_unix_client() click to toggle source
 
               # File mrbgems/mruby-socket/test/unix.rb, line 22
def with_unix_client
  with_unix_server do |path, server|
    UNIXSocket.open(path) do |csock|
      ssock = server.accept
      begin
        yield path, server, ssock, csock
      ensure
        ssock.close unless ssock.closed? rescue nil
      end
    end
  end
end
            
with_unix_server() click to toggle source
 
               # File mrbgems/mruby-socket/test/unix.rb, line 14
def with_unix_server
  unixserver_test_block do |path|
    UNIXServer.open(path) { |server|
      yield path, server
    }
  end
end