Skip to content

Instantly share code, notes, and snippets.

@d4rky-pl
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save d4rky-pl/a34d4ec5d2b40447bcd6 to your computer and use it in GitHub Desktop.

Select an option

Save d4rky-pl/a34d4ec5d2b40447bcd6 to your computer and use it in GitHub Desktop.

Revisions

  1. d4rky-pl revised this gist May 29, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -8,14 +8,14 @@

    ExecJS.runtime = ExecJS::Runtimes::Node
    Benchmark.bmbm(20) do |benchmark|
    benchmark.report('node.js runtime') do
    benchmark.report('node.js') do
    100.times { ExecJS.eval(js_code) }
    end
    end

    ExecJS.runtime = ExecJS::Runtimes::RubyRacer
    Benchmark.bmbm(20) do |benchmark|
    benchmark.report('therubyracer runtime') do
    benchmark.report('therubyracer') do
    100.times { ExecJS.eval(js_code) }
    end
    end
  2. d4rky-pl created this gist May 29, 2015.
    37 changes: 37 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    require 'benchmark'
    require 'execjs'
    require 'therubyracer'

    js_code = '2+2'

    STDOUT.sync = true

    ExecJS.runtime = ExecJS::Runtimes::Node
    Benchmark.bmbm(20) do |benchmark|
    benchmark.report('node.js runtime') do
    100.times { ExecJS.eval(js_code) }
    end
    end

    ExecJS.runtime = ExecJS::Runtimes::RubyRacer
    Benchmark.bmbm(20) do |benchmark|
    benchmark.report('therubyracer runtime') do
    100.times { ExecJS.eval(js_code) }
    end
    end

    # RESULTS:
    #
    # Rehearsal ------------------------------------------------
    # node.js 0.080000 0.050000 11.200000 ( 11.602124)
    # -------------------------------------- total: 11.200000sec
    #
    # user system total real
    # node.js 0.070000 0.050000 11.180000 ( 11.570431)
    # Rehearsal ------------------------------------------------
    # therubyracer 0.060000 0.020000 0.080000 ( 0.064798)
    # --------------------------------------- total: 0.080000sec
    #
    # user system total real
    # therubyracer 0.060000 0.010000 0.070000 ( 0.069190)
    #