simple_bench 0.0.1

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/simple_bench.rb +38 -0
  3. metadata +42 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b686fa3802b9e2d3474375228d35f0a0e05d55d55bf5cf2a6c2770129edfdcdb
4
+ data.tar.gz: 9caa4d420dec441465a49bdca33f3937a191de7bedce60c6a1f78a7ced024a70
5
+ SHA512:
6
+ metadata.gz: 59feb675336a2586b81d2c62c78b5b9c3e1ed868234d316bf251e4c224898d235aeaf95c22b755400cce2ebbeff0baa6b76fa318ed6055a2dff672032deb80ce
7
+ data.tar.gz: 1ccf2f5a51569bfe8382d181596d23887f24fb07d2c71bed5bae55d42f3ab596d6c77886dd20e710de241414962f3679eb01f4f3361d95d96aa99e667193f214
@@ -0,0 +1,38 @@
1
+ module SimpleBench
2
+ class << self
3
+ def simple(method_1, method_2)
4
+ Benchmark.bmbm do |x|
5
+ x.report("#{method_1}_once") { send(method_1) }
6
+ x.report("#{method_2}_once") { send(method_2) }
7
+ end
8
+ end
9
+
10
+ def n_times(method_1, method_2, n)
11
+ Benchmark.bmbm do |x|
12
+ x.report("#{method_1}_once") { send(method_1) }
13
+ x.report("#{method_2}_once") { send(method_2) }
14
+ x.report("#{method_1}_#{n}_times") { n.times { send(method_1) } }
15
+ x.report("#{method_2}_#{n}_times") { n.times { send(method_2) } }
16
+ end
17
+ end
18
+
19
+ def tiered(method_1, method_2)
20
+ Benchmark.bmbm do |x|
21
+ x.report("#{method_1}_once") { send(method_1) }
22
+ x.report("#{method_2}_once") { send(method_2) }
23
+
24
+ n = 1_000
25
+ x.report("#{method_1}_#{n}_times") { n.times { send(method_1) } }
26
+ x.report("#{method_2}_#{n}_times") { n.times { send(method_2) } }
27
+
28
+ n = 10_000
29
+ x.report("#{method_1}_#{n}_times") { n.times { send(method_1) } }
30
+ x.report("#{method_2}_#{n}_times") { n.times { send(method_2) } }
31
+
32
+ n = 100_000
33
+ x.report("#{method_1}_#{n}_times") { n.times { send(method_1) } }
34
+ x.report("#{method_2}_#{n}_times") { n.times { send(method_2) } }
35
+ end
36
+ end
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,42 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_bench
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Clive Corbishley
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-10-31 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/simple_bench.rb
20
+ homepage:
21
+ licenses: []
22
+ metadata: {}
23
+ post_install_message:
24
+ rdoc_options: []
25
+ require_paths:
26
+ - lib
27
+ required_ruby_version: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ required_rubygems_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ requirements: []
38
+ rubygems_version: 3.0.3
39
+ signing_key:
40
+ specification_version: 4
41
+ summary: Simple wrapper for Ruby's Benchmark
42
+ test_files: []