benchmark_driver 0.14.12 → 0.14.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96515f1044447c4af52568f81df7d53d14996eda949fa5043d0d6df4626992d7
4
- data.tar.gz: cf0bd329bf7b4abdb96bc91e8ac18ec3e37ad4b10d2e471b492594afe5d8f813
3
+ metadata.gz: 22df737d5e378a5ea29b9667ffc96fc767427f27b0bb9e21b548b4fb5caf4463
4
+ data.tar.gz: fe45db762725218c739bb412a06189221fb6f5cb0e89a27071a1d302ce90c5bd
5
5
  SHA512:
6
- metadata.gz: c4efb62e805ea16a6903bac564639f17b920721f8b7af3e090d366fdf8bdf1332f36f804f5d8b068cb7859f281a030569a4a7a0e5bdcb494d0871cacc82e6415
7
- data.tar.gz: 6d2c8514a1fcb17ab40d5bdee0b29f6d37a241eb825d1799741fe717ea121e734202f2be14c77e8d85d057da08ddf158ade799ff48866e49307a3e9098124e59
6
+ metadata.gz: 5d903d9b8d9b821f6eefbd21defc201714f6ec2e5436ca9374228756873a7693f37c4974cff38bfb2da01711bf394b8c516c8f6ce974ad19574a484ed780d4a7
7
+ data.tar.gz: 9b7e96da26336be348c4660328330c467f4f92ded7ad60538c23a6bfeb72fb58eddc8e7b7f1cedcccd30d340f34869191b71466e093c2ff93e2b6517ec658c87
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # v0.14.13
2
+
3
+ - Add macOS support to memory runner
4
+ [#53](https://github.com/benchmark-driver/benchmark-driver/pull/53)
5
+
1
6
  # v0.14.12
2
7
 
3
8
  - Reduce the risk of random ZeroDivisionError on warmup
@@ -29,7 +29,12 @@ class BenchmarkDriver::Runner::Memory
29
29
  # @param [Array<BenchmarkDriver::Default::Job>] jobs
30
30
  def run(jobs)
31
31
  # Currently Linux's time(1) support only...
32
- if Etc.uname.fetch(:sysname) != 'Linux'
32
+ case Etc.uname.fetch(:sysname)
33
+ when 'Linux'
34
+ @time_command = ['/usr/bin/time']
35
+ when 'Darwin'
36
+ @time_command = ['/usr/bin/time', '-l']
37
+ else
33
38
  raise "memory output is not supported for '#{Etc.uname[:sysname]}' for now"
34
39
  end
35
40
 
@@ -69,12 +74,9 @@ class BenchmarkDriver::Runner::Memory
69
74
  )
70
75
 
71
76
  with_script(benchmark.render) do |path|
72
- output = IO.popen(['/usr/bin/time', *context.executable.command, path], err: [:child, :out], &:read)
77
+ output = IO.popen([*@time_command, *context.executable.command, path], err: [:child, :out], &:read)
73
78
  if $?.success?
74
- match_data = /^(?<user>\d+.\d+)user\s+(?<system>\d+.\d+)system\s+(?<elapsed1>\d+):(?<elapsed2>\d+.\d+)elapsed.+\([^\s]+\s+(?<maxresident>\d+)maxresident\)k$/.match(output)
75
- raise "Unexpected format given from /usr/bin/time:\n#{out}" unless match_data[:maxresident]
76
-
77
- Integer(match_data[:maxresident]) * 1000.0 # kilobytes -> bytes
79
+ extract_maxresident_from_time_output(output)
78
80
  else
79
81
  $stdout.print(output)
80
82
  BenchmarkDriver::Result::ERROR
@@ -82,6 +84,20 @@ class BenchmarkDriver::Runner::Memory
82
84
  end
83
85
  end
84
86
 
87
+ def extract_maxresident_from_time_output(output)
88
+ case Etc.uname.fetch(:sysname)
89
+ when 'Linux'
90
+ pattern = /^(?<user>\d+.\d+)user\s+(?<system>\d+.\d+)system\s+(?<elapsed1>\d+):(?<elapsed2>\d+.\d+)elapsed.+\([^\s]+\s+(?<maxresident>\d+)maxresident\)k$/
91
+ scale = 1000.0 # kilobytes -> bytes
92
+ when 'Darwin'
93
+ pattern = /^\s+(?<real>\d+\.\d+)\s+real\s+(?<user>\d+\.\d+)\s+user\s+(?<system>\d+\.\d+)\s+sys$\s+(?<maxresident>\d+)\s+maximum resident set size$/
94
+ scale = 1.0
95
+ end
96
+ match_data = pattern.match(output)
97
+ raise "Unexpected format given from /usr/bin/time:\n#{out}" unless match_data[:maxresident]
98
+ Integer(match_data[:maxresident]) * scale
99
+ end
100
+
85
101
  def with_script(script)
86
102
  if @config.verbose >= 2
87
103
  sep = '-' * 30
@@ -1,3 +1,3 @@
1
1
  module BenchmarkDriver
2
- VERSION = '0.14.12'
2
+ VERSION = '0.14.13'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benchmark_driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.12
4
+ version: 0.14.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-03 00:00:00.000000000 Z
11
+ date: 2018-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler