benchmark_g_c 1.0.1 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af54b96fde0fbc9a0e24fe66507ac9374bd5a96a
4
- data.tar.gz: b3fc137a41a8e935a90cdca8f838870ce00cba8e
3
+ metadata.gz: 6a59d6f59ec9b87756e23483ac227e27c9d94dbb
4
+ data.tar.gz: d57f583f194dac07ee8f85aa4fb46741061d2700
5
5
  SHA512:
6
- metadata.gz: 56ed8d4f500b4f15685789245cb680da694b1844c00c5b3dc5b656c3aa31cfe7f41d4dbc4fef1ce55449b576bcac0f8e0bcd415f5747788d44df8fc960c89ad0
7
- data.tar.gz: 0b9ac1c1bb2156a085d2072ed0b18bdaf29831c7e3b9244408ee4589d29d7575a3073f0a46168618b435ca0ba2783190b9f6cef52a787fa63225950d9ccf6ffd
6
+ metadata.gz: 7e7d7ba4ad5c638e828fa413e7243b799bb1159573503fd2772975c03f59b6e43b733555c6833f7ece7d049b11a73725fba5d1af695ace7fc0e683d0649fb959
7
+ data.tar.gz: 9a943a819b2cd47e8d2eb55302cabb544917a4f134dfd8054e4c30ecfd3cb21df79ad4c8a4e207b56285b9486b1e5ca54876e558c3e82859d4835b90bd6cbf4c
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # BenchmarkGC
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/benchmark_g_c`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ A lightweight gem for benchmarking garbage collect stats relevant to memory optimization.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,39 +20,43 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
23
+ ```ruby
25
24
  class Thing
26
25
  include BenchmarkGC
27
26
 
27
+ # A method you want to benchmark
28
28
  def method_name
29
29
  do_some_stuff
30
30
  end
31
+
32
+ # Add this method in order to benchmark (name doesn't matter)
33
+ def check
34
+ bcheck { method_name }
35
+ end
31
36
  end
37
+ ```
38
+
39
+ In a console:
32
40
 
33
- Thing.new.bcheck(logger: false) { method_name }
41
+ ```ruby
42
+ Thing.new.check
43
+ ```
34
44
 
35
- Parameter options (all are optional):
36
- name: (string) Print the name of the benchmarked code
37
- times: (integer) Number of times to run the benchmarked code in succession
38
- logger: (boolean) ActiveRecord::Base.logger should log
45
+ #### Parameter options (all are optional):
46
+ * **name**: *(string)* Print the name of the benchmarked code
47
+ * **times**: *(integer)* Number of times to run the benchmarked code in succession
48
+ * **logger**: *(boolean)* `ActiveRecord::Base.logger` should log
39
49
 
40
- bcheck returns the value of the benchmarked code, making this possible:
50
+ #### bcheck returns the value of the benchmarked code, making this possible:
51
+ ```ruby
41
52
  class Thing
42
53
  ...
43
54
  def method_name
44
55
  bcheck { do_some_stuff }
45
56
  end
46
57
  end
47
-
48
- ## Development
49
-
50
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
51
-
52
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
53
-
54
- ## Contributing
55
-
56
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/benchmark_g_c.
57
-
58
+ ```
59
+ Now you can run any code that uses method_name, and method_name will get benchmarked each time it is run.
58
60
 
59
61
  ## License
60
62
 
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["jnicholasjacques@gmail.com"]
11
11
 
12
12
  spec.summary = %q{Benchmark Garbage Collect stats relevant to memory optimization.}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/jacquesn/benchmark_g_c"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
data/lib/benchmark_g_c.rb CHANGED
@@ -26,8 +26,9 @@ module BenchmarkGC
26
26
  name = options[:name]
27
27
  times = options[:times]
28
28
  logger = options[:logger]
29
- # This should first check if gem is in Rails environment
30
- ActiveRecord::Base.logger = nil unless logger
29
+ if defined? Rails.env
30
+ ActiveRecord::Base.logger = nil unless logger
31
+ end
31
32
  results = []
32
33
  return_value = nil
33
34
  times.times do
@@ -1,3 +1,3 @@
1
1
  module BenchmarkGC
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benchmark_g_c
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Jacques
@@ -55,7 +55,7 @@ files:
55
55
  - bin/setup
56
56
  - lib/benchmark_g_c.rb
57
57
  - lib/benchmark_g_c/version.rb
58
- homepage: ''
58
+ homepage: https://github.com/jacquesn/benchmark_g_c
59
59
  licenses:
60
60
  - MIT
61
61
  metadata: {}