require_bench 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
  SHA256:
3
- metadata.gz: 375788a317a45634f3977fd063fbcd4b409448661910e390c3f9c1c8d0e53267
4
- data.tar.gz: 1342a6540ea2e11ac3a940f9ac76a27f8b0071bbf8702e069d234018ee975a76
3
+ metadata.gz: 0d58bd7b9822f42a37ddb1e9ee4d3d222b6f26080b09ed4accdc29b8e81732c8
4
+ data.tar.gz: 4547c56e2e4dcdfff2a0d05a96bb92e1b0cfa895ba3a4cd766f287be540e2591
5
5
  SHA512:
6
- metadata.gz: 7680f7448949d469594ebc58314fb4a2063269b112a47c3e796b10768eece4242f9d86d321457dacff3d33a6ce21092ece0f9b1bb563509686d82d09abe9d411
7
- data.tar.gz: aeca5a5ee2d4d5e2785598951a229eb8bd05cc2cb3ae14ecbc48ffe57922580de2e8001bfce790c9410a3be05700fd549da8387a214ecad63eebe1fee09540b6
6
+ metadata.gz: c5821d49695eec9eac440a0d45d0d7d754d9e2c13c0e8b133d105b4c219c34e3c55ff28914f38fae603980ca27705bcfa45ee57fe3d404b4b5de5534205e7ad9
7
+ data.tar.gz: 2b4cb7596ae3730dc02f4c1da00cb2e2c4ce89e5c51fbfa111bf4516e32752e867bab4a79f9537c81ef8a1414b57bf261d2e5fe150f3cb15bf1f26bba570dd7a
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.5.7
data/.travis.yml CHANGED
@@ -17,7 +17,7 @@ after_script:
17
17
 
18
18
  before_install:
19
19
  - gem update --system
20
- - gem install bundler -v 1.16.5
20
+ - gem install bundler
21
21
 
22
22
  install:
23
23
  - bundle install
@@ -29,4 +29,4 @@ cache: bundler
29
29
  language: ruby
30
30
  sudo: false
31
31
  rvm:
32
- - 2.5.1
32
+ - 2.5.8
data/README.md CHANGED
@@ -8,13 +8,15 @@ This is an extraction of a debugging tool that I have copy/pasted into many proj
8
8
 
9
9
  *Warning*: This gem is for debugging problems. It uses a global **$** variable, which is sad practice. It uses it as a safety semaphore, so I consider it justified. If you can think of a better way to implement the safety semaphore, let me know!
10
10
 
11
+ *Caveat*: This gem has no effects unless a particular environment variable is set. It does nothing at all unless it is 'invoked' by detection of the environment variable (`ENV['REQUIRE_BENCH'] == 'true'`). The *Warning* above is mitigated by the gem not having any of its code activated under normal circumstances.
12
+
11
13
  | Project | RequireBench |
12
14
  |------------------------ | ----------------------- |
13
15
  | gem name | [require_bench](https://rubygems.org/gems/require_bench) |
14
16
  | license | [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) |
15
17
  | download rank | [![Downloads Today](https://img.shields.io/gem/rd/require_bench.svg)](https://github.com/pboling/require_bench) |
16
18
  | version | [![Version](https://img.shields.io/gem/v/require_bench.svg)](https://rubygems.org/gems/require_bench) |
17
- | dependencies | [![Depfu](https://badges.depfu.com/badges/272ce0df3bc6df5cbea9354e2c3b65af/count.svg)](https://depfu.com/github/pboling/require_bench?project_id=5614) |
19
+ | dependencies | [![Depfu](https://badges.depfu.com/badges/247bffc753b0cd49d3c08ce03b5c251c/count.svg)](https://depfu.com/github/pboling/require_bench?project_id=5824) |
18
20
  | continuous integration | [![Build Status](https://travis-ci.org/pboling/require_bench.svg?branch=master)](https://travis-ci.org/pboling/require_bench) |
19
21
  | test coverage | [![Test Coverage](https://api.codeclimate.com/v1/badges/18523205c207a2b53045/test_coverage)](https://codeclimate.com/github/pboling/require_bench/test_coverage) |
20
22
  | maintainability | [![Maintainability](https://api.codeclimate.com/v1/badges/18523205c207a2b53045/maintainability)](https://codeclimate.com/github/pboling/require_bench/maintainability) |
@@ -57,7 +59,7 @@ Add an environment variable, however you normally do such things, so that in Rub
57
59
  ENV['REQUIRE_BENCH'] == 'true'
58
60
  ```
59
61
 
60
- Any value other than `'true'` means RubyBench is still turned off.
62
+ Any value other than `'true'` means RequireBench is still turned off.
61
63
 
62
64
  ### Handy Rake Task for Rails:
63
65
 
@@ -114,23 +116,18 @@ When running from command line, you will see output as the Rails app boots.
114
116
 
115
117
  If the output is too noisy from deep libraries you can add a regex to skip benchmarking of files that match.
116
118
 
117
- If the value is set in the shell, it should be a string. RequireBench will split the string by comma, Regexp escape each value, and join together with pipe (`|`) to form the regex pattern.
118
-
119
119
  ```bash
120
120
  export REQUIRE_BENCH_SKIP_PATTERN=activesupport,rspec
121
121
  ```
122
122
 
123
- If the `ENV['REQUIRE_BENCH_SKIP_PATTERN']` value is set in Ruby, it can be one of:
124
- * a string, to be split by comma, each Regexp escaped, then joined by pipe (`|`)
125
- * an array of strings, each to be Regexp escaped, then joined by pipe (`|`)
126
- * a Regexp object, which will be used as is.
123
+ `ENV['REQUIRE_BENCH_SKIP_PATTERN']` must be one of:
124
+ * a string, to be split by comma (`,`), each Regexp escaped, then joined by pipe (`|`) with `Regexp.union`
125
+ * a string, to be split by pipe (`|`), each Regexp escaped, then joined by pipe (`|`) with `Regexp.union`
127
126
 
128
127
  ```ruby
129
128
  ENV['REQUIRE_BENCH_SKIP_PATTERN'] = 'activesupport,rspec'
130
129
  # or
131
- ENV['REQUIRE_BENCH_SKIP_PATTERN'] = [ 'activesupport', 'rspec' ]
132
- # or
133
- ENV['REQUIRE_BENCH_SKIP_PATTERN'] = Regexp.new('activesupport|rspec')
130
+ ENV['REQUIRE_BENCH_SKIP_PATTERN'] = 'activesupport|rspec'
134
131
  ```
135
132
 
136
133
  Any file being required that matches the pattern will use the standard, rather than the benchmarked, require.
data/lib/require_bench.rb CHANGED
@@ -8,6 +8,17 @@ require 'require_bench/version'
8
8
 
9
9
  module RequireBench
10
10
  TIMINGS = Hash.new { |h, k| h[k] = 0.0 }
11
+ skips = ENV['REQUIRE_BENCH_SKIP_PATTERN']
12
+ if skips
13
+ skip_pattern = case skips
14
+ when /,/ then
15
+ Regexp.union(*skips.split(','))
16
+ when /\|/ then
17
+ Regexp.union(*skips.split('|'))
18
+ end
19
+ puts "[RequireBench] Setting REQUIRE_BENCH_SKIP_PATTERN to #{skip_pattern}"
20
+ end
21
+ SKIP_PATTERN = skips
11
22
 
12
23
  if ENV['REQUIRE_BENCH'] == 'true'
13
24
  def require_with_timing(file)
@@ -30,19 +41,6 @@ module RequireBench
30
41
  end
31
42
 
32
43
  if ENV['REQUIRE_BENCH'] == 'true'
33
- skips = ENV['REQUIRE_BENCH_SKIP_PATTERN']
34
- if skips
35
- skip_pattern = case skips
36
- when Regexp then
37
- skips
38
- when Array then
39
- Regexp.new(skips.map { |x| Regexp.escape(x) }.join('|'))
40
- when String then
41
- Regexp.new(skips.split(',').map { |x| Regexp.escape(x) }.join('|'))
42
- end
43
- puts "[RequireBench] Setting REQUIRE_BENCH_SKIP_PATTERN to #{skip_pattern}"
44
- ENV['REQUIRE_BENCH_SKIP_PATTERN'] = skip_pattern
45
- end
46
44
  # A Kernel hack that adds require timing to find require problems in app.
47
45
  module Kernel
48
46
  alias require_without_timing require
@@ -53,7 +51,9 @@ if ENV['REQUIRE_BENCH'] == 'true'
53
51
  # Global $ variable, which is always truthy while inside the hack, is to
54
52
  # prevent a scenario that might result in infinite recursion.
55
53
  return require_without_timing(file) if $require_bench_semaphore
56
- return require_without_timing(file) if ENV['REQUIRE_BENCH_SKIP_PATTERN'] && file =~ ENV['REQUIRE_BENCH_SKIP_PATTERN']
54
+ if RequireBench::SKIP_PATTERN && file =~ RequireBench::SKIP_PATTERN
55
+ return require_without_timing(file)
56
+ end
57
57
 
58
58
  RequireBench.require_with_timing(file)
59
59
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RequireBench
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.2'
5
5
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ['lib']
25
25
  spec.license = 'MIT'
26
26
 
27
- spec.add_development_dependency 'bundler', '~> 1.16'
28
- spec.add_development_dependency 'rake', '~> 10.0'
29
- spec.add_development_dependency 'rspec', '~> 3.0'
27
+ spec.add_development_dependency 'bundler', '~> 2.0'
28
+ spec.add_development_dependency 'rake', '~> 13.0'
29
+ spec.add_development_dependency 'rspec', '~> 3.9'
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: require_bench
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
  - Peter Boling
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-21 00:00:00.000000000 Z
11
+ date: 2020-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: '2.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '3.9'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: '3.9'
55
55
  description: Ruby app loading slowly, or never? Discover bootstrapping issues in Ruby
56
56
  by benchmarking "Kernel.require"
57
57
  email:
@@ -65,6 +65,7 @@ files:
65
65
  - ".rspec"
66
66
  - ".rubocop.yml"
67
67
  - ".ruby-version"
68
+ - ".tool-versions"
68
69
  - ".travis.yml"
69
70
  - CODE_OF_CONDUCT.md
70
71
  - Gemfile
@@ -97,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
98
  version: '0'
98
99
  requirements: []
99
100
  rubyforge_project:
100
- rubygems_version: 2.7.6
101
+ rubygems_version: 2.7.6.2
101
102
  signing_key:
102
103
  specification_version: 4
103
104
  summary: Discover bootstrapping issues in Ruby by benchmarking "Kernel.require"