File: run.rb

package info (click to toggle)
ruby-subexec 0.2.3%2Bgh-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 116 kB
  • ctags: 6
  • sloc: ruby: 156; sh: 3; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 677 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
begin
  require 'bundler'
  Bundler.setup(:default, :development)
rescue LoadError => e
  # Fall back on doing an unlocked resolve at runtime.
  $stderr.puts e.message
  $stderr.puts "Try running `bundle install`"
  exit!
end

require 'benchmark'

TEST_PROG = File.join(File.expand_path('../spec', File.dirname(__FILE__)), 'helloworld.sh')

n = 100
Benchmark.bm(20) do |x|
  x.report("via Subexec x#{n}") do
    n.times do
      sub = Subexec.run "#{TEST_PROG} 0", :timeout => 2
      raise if sub.output != "Hello\nWorld\n"
    end
  end

  x.report("via `` x#{n}") do
    n.times do
      output = `#{TEST_PROG} 0`
      raise if output != "Hello\nWorld\n"
    end
  end
end