Sha256: acd52f2090e069e2c91c3adb8b7c2bc60c3bdaf8d979073d03d4889c8347277b

Contents?: true

Size: 618 Bytes

Versions: 4

Compression:

Stored size: 618 Bytes

Contents

require 'h8'

def timing name, repetitions = 1, scale = 1
  s = Time.now
  repetitions.times { yield }
  t = Time.now - s
  if scale != 1
    puts "#{name}\t: #{t} scaled: #{t*scale}"
  else
    puts "#{name}\t: #{t}"
  end
rescue
  puts "*** #{$!}"
  raise
end

class Console
  def log *args
    puts args.join(' ')
  end
end

def js_context
  cxt         = H8::Context.new
  cxt[:print] = -> (*args) { puts args.join(' ') }
  cxt[:console] = Console
  cxt
end

def coffee script_file_name
  @base ||= File.dirname(File.expand_path(__FILE__))
  H8::Coffee.compile open("#{@base}/#{script_file_name}.coffee").read
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
h8-0.4.8 benchmark/tools.rb
h8-0.4.5 benchmark/tools.rb
h8-0.4.0 benchmark/tools.rb
h8-0.3.0 benchmark/tools.rb