posix-spawn 0.3.12 → 0.3.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e7aaeb2727c0c2d0d4b1055fee451289ddd510b
4
- data.tar.gz: 87bcf9d8cc5cd759a6dc985a683b2a6d44dd8152
3
+ metadata.gz: 586d0f0f9057e34308bf74b8012308d58554be84
4
+ data.tar.gz: fc46031fe4302b9c09bac390c758006e06d42a14
5
5
  SHA512:
6
- metadata.gz: 4f94bf7abd676780045ffb4c7d010cb0cc626d1fe6bbe84fab3126c4764a14f3828266db52f5ffa1eed5827ce0cac988b53f443bf9fed2bfd37110f6b55092f5
7
- data.tar.gz: 20f06443465c1b96e06f988ca0c9b74df329cb13bbc0cb132217fa9453d35680e539de59492bfb2fe65bdd37c5c3d2b36a970899fd5fe860a04c0a9206530a09
6
+ metadata.gz: 41c48ddad2fb6bd679db842a9ab7afb37b0c07963b143e8c3e9537a48216b0b61a7761c2f2214fdfd5f30072c9d0429717aa65cfc2e005e1797a7b2802486391
7
+ data.tar.gz: f18771b44bff3cf3ce268abb4969ab2a4750df248bcab1ed027fcb84e475b1172aaadfb7051451dda475391cfeabfe8100fd4b1dc818ba82d7e20f9bfcd82188
@@ -1,117 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
- #/ Usage: posix-spawn-benchmark [-n <count>] [-m <mem-size>]
3
- #/ Run posix-spawn (Ruby extension) benchmarks and report to standard output.
4
- #/
5
- #/ Options:
6
- #/ -n, --count=NUM total number of processes to spawn.
7
- #/ -m, --mem-size=MB RES size to bloat to before performing benchmarks.
8
- #/ -g, --graph benchmark at 10MB itervals up to RES and graph results.
9
- #/
10
- #/ Benchmarks run with -n 1000 -m 100 by default.
11
- require 'optparse'
12
- require 'posix-spawn'
13
- require 'benchmark'
14
- include Benchmark
15
-
16
- allocate = 100 * (1024 ** 2)
17
- iterations = 1_000
18
- graphmode = false
19
- ARGV.options do |o|
20
- o.set_summary_indent(' ')
21
- o.on("-n", "--count=num") { |val| iterations = val.to_i }
22
- o.on("-m", "--mem-size=MB") { |val| allocate = val.to_i * (1024 ** 2) }
23
- o.on("-g", "--graph") { graphmode = true }
24
- o.on_tail("-h", "--help") { exec "grep ^#/ <'#{__FILE__}' |cut -c4-" }
25
- o.parse!
26
- end
27
-
28
- if graphmode
29
- bloat = []
30
- data = {}
31
- chunk = allocate / 10
32
- max = 0
33
-
34
- 10.times do
35
- puts "allocating #{chunk / (1024 ** 2)}MB (#{(bloat.size+1) * chunk / (1024 ** 2)}MB total)"
36
- bloat << ('x' * chunk)
37
- # size = bloat.size / (1024 ** 2)
38
-
39
- %w[ fspawn pspawn ].each do |type|
40
- print " - benchmarking #{type}... "
41
- time = Benchmark.realtime do
42
- iterations.times do
43
- pid = POSIX::Spawn.send(type, 'true')
44
- Process.wait(pid)
45
- end
46
- end
47
- puts "done (#{time})"
48
-
49
- data[type] ||= []
50
- data[type] << time
51
- max = time if time > max
52
- end
53
- end
54
-
55
- max = max < 0.5 ? (max * 10).round / 10.0 : max.ceil
56
- minmb, maxmb = chunk/(1024**2), allocate/(1024**2)
57
- series = %w[ fspawn pspawn ].map{|name| data[name].map{|d| "%.2f" % d }.join(',') }
58
-
59
- chart = {
60
- :chs => '900x200',
61
- :cht => 'bvg', # grouped vertical bar chart
62
- :chtt => "posix-spawn-benchmark --graph --count #{iterations} --mem-size #{maxmb} (#{RUBY_PLATFORM})",
63
-
64
- :chf => 'bg,s,f8f8f8', # background
65
- :chbh => 'a,5,25', # 25px between bar groups
66
-
67
- :chd => "t:#{series.join('|')}", # data
68
- :chds => "0,#{max}", # scale
69
- :chdl => 'fspawn (fork+exec)|pspawn (posix_spawn)', # legend
70
- :chco => '1f77b4,ff7f0e', # colors
71
-
72
- :chxt => 'x,y',
73
- :chxr => "1,0,#{max},#{max/5}", # y labels up to max time
74
- :chxs => '1N** secs', # y labels are +=' secs'
75
- :chxl => "0:|#{minmb.step(maxmb, maxmb/10).map{ |mb| "#{mb} MB"}.join('|')}", # x bucket labels
76
- }
77
-
78
- url = "https://chart.googleapis.com/chart?"
79
- url += chart.map do |key, val|
80
- "#{key}=#{val.gsub(' ','%20').gsub('(','%28').gsub(')','%29').gsub('+','%2B')}"
81
- end.join('&')
82
- url += '#.png'
83
-
84
- puts url
85
-
86
- exit!
87
- end
88
-
89
- puts "benchmarking fork/exec vs. posix_spawn over #{iterations} runs" +
90
- " at #{allocate / (1024 ** 2)}M res"
91
-
92
- # bloat the process
93
- bloat = 'x' * allocate
94
-
95
- # run the benchmarks
96
- bm 40 do |x|
97
- x.report("fspawn (fork/exec):") do
98
- iterations.times do
99
- pid = POSIX::Spawn.fspawn('true')
100
- Process.wait(pid)
101
- end
102
- end
103
- x.report("pspawn (posix_spawn):") do
104
- iterations.times do
105
- pid = POSIX::Spawn.pspawn('true')
106
- Process.wait(pid)
107
- end
108
- end
109
- if Process.respond_to?(:spawn)
110
- x.report("spawn (native):") do
111
- iterations.times do
112
- pid = Process.spawn('true')
113
- Process.wait(pid)
114
- end
115
- end
116
- end
117
- end
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'posix-spawn-benchmark' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("posix-spawn", "posix-spawn-benchmark")
@@ -45,7 +45,7 @@ static VALUE rb_mPOSIXSpawn;
45
45
  * an actual fd number:
46
46
  * - The symbols :in, :out, or :err for fds 0, 1, or 2.
47
47
  * - An IO object. (IO#fileno is returned)
48
- * - A Fixnum.
48
+ * - An Integer.
49
49
  *
50
50
  * Returns the fd number >= 0 if one could be established, or -1 if the object
51
51
  * does not map to an fd.
@@ -56,8 +56,12 @@ posixspawn_obj_to_fd(VALUE obj)
56
56
  int fd = -1;
57
57
  switch (TYPE(obj)) {
58
58
  case T_FIXNUM:
59
- /* Fixnum fd number */
60
- fd = FIX2INT(obj);
59
+ case T_BIGNUM:
60
+ /* Integer fd number
61
+ * rb_fix2int takes care of raising if the provided object is a
62
+ * Bignum and is out of range of an int
63
+ */
64
+ fd = (int)rb_fix2int(obj);
61
65
  break;
62
66
 
63
67
  case T_SYMBOL:
@@ -94,7 +98,7 @@ posixspawn_obj_to_fd(VALUE obj)
94
98
  /*
95
99
  * Hash iterator that sets up the posix_spawn_file_actions_t with addclose
96
100
  * operations. Only hash pairs whose value is :close are processed. Keys may
97
- * be the :in, :out, :err, an IO object, or a Fixnum fd number.
101
+ * be the :in, :out, :err, an IO object, or an Integer fd number.
98
102
  *
99
103
  * Returns ST_DELETE when an addclose operation was added; ST_CONTINUE when
100
104
  * no operation was performed.
@@ -85,7 +85,7 @@ module POSIX
85
85
  #
86
86
  # spawn(command, :chdir => "/var/tmp")
87
87
  #
88
- # The :in, :out, :err, a Fixnum, an IO object or an Array option specify
88
+ # The :in, :out, :err, an Integer, an IO object or an Array option specify
89
89
  # fd redirection. For example, stderr can be merged into stdout as follows:
90
90
  #
91
91
  # spawn(command, :err => :out)
@@ -460,11 +460,11 @@ module POSIX
460
460
 
461
461
  # Determine whether object is fd-like.
462
462
  #
463
- # Returns true if object is an instance of IO, Fixnum >= 0, or one of the
463
+ # Returns true if object is an instance of IO, Integer >= 0, or one of the
464
464
  # the symbolic names :in, :out, or :err.
465
465
  def fd?(object)
466
466
  case object
467
- when Fixnum
467
+ when Integer
468
468
  object >= 0
469
469
  when :in, :out, :err, STDIN, STDOUT, STDERR, $stdin, $stdout, $stderr, IO
470
470
  true
@@ -486,7 +486,7 @@ module POSIX
486
486
  STDOUT
487
487
  when :err, 2
488
488
  STDERR
489
- when Fixnum
489
+ when Integer
490
490
  object >= 0 ? IO.for_fd(object) : nil
491
491
  when IO
492
492
  object
@@ -1,5 +1,5 @@
1
1
  module POSIX
2
2
  module Spawn
3
- VERSION = '0.3.12'
3
+ VERSION = '0.3.13'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posix-spawn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.12
4
+ version: 0.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-11-03 00:00:00.000000000 Z
12
+ date: 2017-01-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler
@@ -92,9 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  requirements: []
94
94
  rubyforge_project:
95
- rubygems_version: 2.4.5.1
95
+ rubygems_version: 2.5.2
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: posix_spawnp(2) for ruby
99
99
  test_files: []
100
- has_rdoc: