simplest_benchmark 0.0.2

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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NGZmOWFmNmNjYzQwZWFjNmIyNzE3YWU1OWQxZWNjNzYyYWQ0ZGY4Zg==
5
+ data.tar.gz: !binary |-
6
+ OWUzYTQzODJkODkwOGYxY2NmYjU2NmQ1OTBlMmM5NDNjOTk3ZjA1OQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZTIwMTQxZjI5YTgxMmQwMDYwMmFhNjg2MGQxMjIxOWM2NWRjYWRjZTU2Mzcz
10
+ ODRjYjAxMWIxYzA4ZTA0OTE0MmRlZDE4YzFmZTk0YTBmMzgyYjdkOWZiNmQ4
11
+ YTQ3ZmYwNGU1ZmRhZmRiY2M3ODYyZmZkYmVlY2ZjM2EzNWNhMzk=
12
+ data.tar.gz: !binary |-
13
+ MjdiYzBlMDg1NjYzNzk0MTQ2OTYwYTA4MDM4NTNjMzkzYmExMGIwMDQ3YWQz
14
+ OGUzZDYxMjM1NWZjMmE1ZGQ3MzRkZmQ4Mjk2ZGZkMThjZTkxZjljZWEyYjM0
15
+ ZWEyM2NiYjYxYjk3ZmIzNjI4ODViMjNkOWYzNGNhMmRmM2UwMDM=
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --color
2
+ --require spec_helper
3
+ --format documentation
4
+ --order rand
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ simple-benchmark
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+ gem 'pry'
3
+ # Specify your gem's dependencies in simplest_benchmark.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,44 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ simplest_benchmark (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.0)
10
+ diff-lcs (1.2.5)
11
+ method_source (0.8.2)
12
+ pry (0.10.3)
13
+ coderay (~> 1.1.0)
14
+ method_source (~> 0.8.1)
15
+ slop (~> 3.4)
16
+ rake (10.4.2)
17
+ rspec (3.4.0)
18
+ rspec-core (~> 3.4.0)
19
+ rspec-expectations (~> 3.4.0)
20
+ rspec-mocks (~> 3.4.0)
21
+ rspec-core (3.4.1)
22
+ rspec-support (~> 3.4.0)
23
+ rspec-expectations (3.4.0)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.4.0)
26
+ rspec-its (1.2.0)
27
+ rspec-core (>= 3.0.0)
28
+ rspec-expectations (>= 3.0.0)
29
+ rspec-mocks (3.4.0)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.4.0)
32
+ rspec-support (3.4.1)
33
+ slop (3.6.0)
34
+
35
+ PLATFORMS
36
+ ruby
37
+
38
+ DEPENDENCIES
39
+ bundler (~> 1.6)
40
+ pry
41
+ rake (~> 10.0)
42
+ rspec (~> 3.0)
43
+ rspec-its (~> 1.0)
44
+ simplest_benchmark!
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 carlosgab83
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1 @@
1
+ # simplest_benchmark
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec)
4
+
5
+ task :default => :spec
@@ -0,0 +1,27 @@
1
+ #encoding: utf-8
2
+
3
+ require_relative 'simplest_benchmark_logger.rb'
4
+
5
+ module SimplestBenchmark
6
+ include SimplestBenchmarkLogger
7
+
8
+ attr_accessor :miliseconds, :logger, :rails_app
9
+
10
+ def sb_begin(msg = "", other_info = "")
11
+ time = Time.now
12
+ miliseconds << time.to_f
13
+ log "SimplestBenchmark\t#{time}\t#{time.to_f}\tBEGIN\t#{miliseconds.count-1}\t#{msg}\t\t#{other_info}"
14
+ end
15
+
16
+ def sb_end(msg, other_info="")
17
+ time = Time.now
18
+ time_spent = time.to_f - miliseconds.last
19
+ miliseconds.pop
20
+ log "SimplestBenchmark\t#{time}\t#{time.to_f}\tEND\t#{miliseconds.count}\t#{msg}\t#{time_spent}\t#{other_info}"
21
+ return time_spent
22
+ end
23
+
24
+ def miliseconds
25
+ @miliseconds ||= []
26
+ end
27
+ end
@@ -0,0 +1,19 @@
1
+ #encoding: utf-8
2
+ module SimplestBenchmarkLogger
3
+
4
+ def log(msg)
5
+ rails_app ? logger.debug(msg) : custom_logger.write("#{msg}\n")
6
+ end
7
+
8
+ def logger
9
+ @logger ||= rails_app ? Rails.logger : custom_logger
10
+ end
11
+
12
+ def custom_logger
13
+ File.open("simplest_benchmark.log", "a")
14
+ end
15
+
16
+ def rails_app
17
+ @rails_app ||= defined?(Rails)
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'simplest_benchmark'
3
+ s.version = '0.0.2'
4
+ s.date = '2015-11-28'
5
+ s.summary = "Benchmark your code fastest, simplest and get pragmatic results."
6
+ s.description = "Counts miliseconds transcurred between bs_begin and bs_end ruby calls. It can be nested for benchmark each part of the code you want. Documentation and code in https://github.com/carlosgab83/simplest_benchmark/"
7
+ s.authors = ["Carlos Ochoa"]
8
+ s.email = 'carlosgab83@gmail.com'
9
+ s.files = `git ls-files -z`.split("\x0")
10
+ s.homepage = 'http://rubygems.org/gems/simplest_benchmark'
11
+ s.license = 'MIT'
12
+
13
+ s.files = `git ls-files -z`.split("\x0")
14
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
15
+ s.require_paths = ["lib"]
16
+
17
+
18
+ s.add_development_dependency "bundler", "~> 1.6"
19
+ s.add_development_dependency "rake", "~> 10.0"
20
+ s.add_development_dependency "rspec", "~> 3.0"
21
+ s.add_development_dependency "rspec-its", "~> 1.0"
22
+ end
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ require 'simplest_benchmark'
4
+
5
+ RSpec.describe SimplestBenchmark do
6
+
7
+ context "with simple calls" do
8
+
9
+ it "returns time_spent > 0" do
10
+ sb_begin("iteration")
11
+
12
+ 10.times {|i| i*10}
13
+
14
+ t = sb_end("iteration")
15
+ expect(t).to be > 0
16
+ end
17
+
18
+ it "logs correctly" do
19
+ pending("not implemented yet.")
20
+ fail
21
+ end
22
+ end
23
+
24
+ context "with nested calls" do
25
+ it "returns coherent time spent" do
26
+ t,t0 = 0
27
+
28
+ sb_begin("iteration1")
29
+
30
+ 10.times {|i|
31
+ i*10
32
+
33
+ sb_begin("iteration2")
34
+
35
+ 20.times{|j|
36
+ j*10
37
+ }
38
+
39
+ t0 = sb_end("iteration2")
40
+ }
41
+
42
+ t = sb_end("iteration")
43
+ expect(t).to be > t0
44
+ end
45
+
46
+ it "logs correctly" do
47
+ pending("not implemented yet.")
48
+ fail
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,11 @@
1
+ RSpec.configure do |config|
2
+
3
+ config.expect_with :rspec do |expectations|
4
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
5
+ end
6
+
7
+ config.mock_with :rspec do |mocks|
8
+ mocks.verify_partial_doubles = true
9
+ end
10
+
11
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simplest_benchmark
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Carlos Ochoa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-its
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ description: Counts miliseconds transcurred between bs_begin and bs_end ruby calls.
70
+ It can be nested for benchmark each part of the code you want. Documentation and
71
+ code in https://github.com/carlosgab83/simplest_benchmark/
72
+ email: carlosgab83@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .rspec
78
+ - .ruby-gemset
79
+ - .ruby-version
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - LICENSE
83
+ - README.md
84
+ - Rakefile
85
+ - lib/simplest_benchmark.rb
86
+ - lib/simplest_benchmark_logger.rb
87
+ - simplest_benchmark.gemspec
88
+ - spec/lib/simplest_benchmark_spec.rb
89
+ - spec/spec_helper.rb
90
+ homepage: http://rubygems.org/gems/simplest_benchmark
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.4.2
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Benchmark your code fastest, simplest and get pragmatic results.
114
+ test_files:
115
+ - spec/lib/simplest_benchmark_spec.rb
116
+ - spec/spec_helper.rb