benchmark_time 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # BenchmarkTime
2
2
 
3
3
  Benchmark the execution time of an arbitrary block of code. Specify concurrent
4
- threads and number of execution loops for more robust sampling.
4
+ threads and number of execution loops.
5
5
 
6
6
  ## Installation
7
7
 
@@ -18,26 +18,36 @@ Or install it yourself as:
18
18
  $ gem install benchmark_time
19
19
 
20
20
  ## Usage
21
+
21
22
  require 'benchmark_time'
23
+ require 'bunny'
22
24
 
23
- benchmark_time(threads: 10, loops: 2) do
25
+ # Benchmark connecting and filing an item into rabbitmq with bunny
26
+ benchmark_time(num_threads: 10, num_loops: 5) do
24
27
  conn = Bunny.new
25
28
  conn.start
26
29
  ch = conn.create_channel
27
30
  q = ch.queue("test1")
28
- q.publish(@data)
31
+ q.publish('hello bunny')
29
32
  conn.stop
30
33
  end
31
34
 
32
35
  ->
36
+ --------------------------------------------------------------
37
+
38
+ Samples: 50
39
+
40
+ Min time (ms): 6
41
+
42
+ Max time (ms): 157
43
+
44
+ Average time (ms): 32.6
45
+
46
+ Standard Deviation (ms): 25.33046886777315
47
+
48
+ --------------------------------------------------------------
49
+
33
50
 
34
- "----------------------------------------"
35
- "Samples: 20"
36
- "Min time: 0.059449195861816406"
37
- "Max time: 0.15325689315795898"
38
- "Average time: 0.10354292392730713"
39
- "Standard Deviation: 0.027390028761805192"
40
- "----------------------------------------"
41
51
 
42
52
  ## Contributing
43
53
 
@@ -14,13 +14,14 @@ module BenchmarkTime
14
14
  # Create and run a new benchmark with output to the command line
15
15
  # ==== Options
16
16
  # +:work_warmup_proc:+ A proc to call for each thread. this can pre-warm connections,
17
- # or perform oother non-timed work.
18
- # +:threads+ Number of concurrent threads to execute the work
19
- # +:loops+ Number of times to call the block in each execution thread.
17
+ # or perform other non-timed work.
18
+ # +: num_threads+ Number of concurrent threads to execute the work
19
+ # +: num_loops+ Number of times to call the block in each execution thread.
20
20
  def initialize(options = {}, &work_block)
21
21
  default_options = {num_threads: 10, num_loops: 10, print_samples: true, work_warmup_proc: nil}
22
22
  options = default_options.merge(options)
23
- options.to_instance_variables(binding, define: :attr_reader)
23
+ # experiment: auto-create instance variables from hash...
24
+ options.to_instance_variables(binding, define: :attr_reader)
24
25
  @threads = []
25
26
  @results = []
26
27
  @results.extend(EnumerableStatistics)
@@ -1,4 +1,6 @@
1
1
  module HashExtensions
2
+
3
+ # experiment to make hash arguments into instance variables
2
4
  def to_instance_variables(bind, opts={})
3
5
  each do |key, val|
4
6
  bind.eval("@#{key}=#{val.inspect}")
@@ -1,3 +1,3 @@
1
1
  module BenchmarkTime
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -1,5 +1,5 @@
1
1
  require_relative "../lib/benchmark_time"
2
2
 
3
- benchmark_time(threads: 10, loops: 2, print_samples: true) do
3
+ benchmark_time(num_threads: 10, num_loops: 2, print_samples: true) do
4
4
  sleep 1.00
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benchmark_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: