In Files

  • benchmark/bm_ao_render.rb
  • benchmark/bm_app_lc_fizzbuzz.rb
  • benchmark/bm_fib.rb
  • benchmark/bm_so_lists.rb
  • doc/language/generator.rb
  • doc/language/mrbdoc/mrbdoc.rb
  • examples/targets/build_config_ArduinoDue.rb
  • examples/targets/build_config_IntelGalileo.rb
  • examples/targets/build_config_chipKITMax32.rb
  • minirake
  • mrbgems/mruby-bin-debugger/bintest/mrdb.rb
  • mrbgems/mruby-enum-ext/test/enum.rb
  • mrbgems/mruby-kernel-ext/test/kernel.rb
  • mrbgems/mruby-math/test/math.rb
  • mrbgems/mruby-object-ext/mrblib/object.rb
  • mrbgems/mruby-object-ext/test/object.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

DOC_DIR
DOC_ROOT
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

MRUBY_ROOT
N
NAO_SAMPLES
NSUBSAMPLES
NUM

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

PIC32_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
TARGET_PATH
WRITE_LINE_NO

Public Class Methods

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
            
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

check_float(a, b) click to toggle source

Performs fuzzy check for equality on methods returning floats on the basis of the Math::TOLERANCE constant.

 
               # File mrbgems/mruby-math/test/math.rb, line 7
def check_float(a, b)
  tolerance = Math::TOLERANCE
  a = a.to_f
  b = b.to_f
  if a.finite? and b.finite?
    (a-b).abs < tolerance
  else
    true
  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 then
    i = 255.0
  end
  if i < 0.0 then
    i = 0.0
  end
  i.to_i
end
            
each() click to toggle source
 
               # File mrbgems/mruby-enum-ext/test/enum.rb, line 151
def each
  yield [1,2]
  yield [3,4]
end
            
m() click to toggle source
 
               # File mrbgems/mruby-kernel-ext/test/kernel.rb, line 7
def m; __method__; 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 then
    basis[1].x = 1.0
  elsif n.y < 0.6 and n.y > -0.6 then
    basis[1].y = 1.0
  elsif n.z < 0.6 and n.z > -0.6 then
    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
            
tap{|x|...} → obj click to toggle source

Yields x to the block, and then returns x. The primary purpose of this method is to “tap into” a method chain, in order to perform operations on intermediate results within the chain.

(1..10) .tap {|x| puts “original: #{x.inspect}”}

.to_a                .tap {|x| puts "array: #{x.inspect}"}
.select {|x| x%2==0} .tap {|x| puts "evens: #{x.inspect}"}
.map { |x| x*x }     .tap {|x| puts "squares: #{x.inspect}"}
 
               # File mrbgems/mruby-object-ext/mrblib/object.rb, line 15
def tap
  yield self
  self
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)
  while (not 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 then
    p "not SIZE"
    0
  else
    # compare li1 and li2 for equality
    if li1 != li2 then
      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
            

Private Instance Methods

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