require_bench 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.pryrc +3 -1
- data/Gemfile +4 -2
- data/README.md +2 -0
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/lib/require_bench.rb +5 -3
- data/lib/require_bench/tasks.rb +4 -2
- data/lib/require_bench/version.rb +3 -1
- data/require_bench.gemspec +16 -14
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 375788a317a45634f3977fd063fbcd4b409448661910e390c3f9c1c8d0e53267
|
4
|
+
data.tar.gz: 1342a6540ea2e11ac3a940f9ac76a27f8b0071bbf8702e069d234018ee975a76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7680f7448949d469594ebc58314fb4a2063269b112a47c3e796b10768eece4242f9d86d321457dacff3d33a6ce21092ece0f9b1bb563509686d82d09abe9d411
|
7
|
+
data.tar.gz: aeca5a5ee2d4d5e2785598951a229eb8bd05cc2cb3ae14ecbc48ffe57922580de2e8001bfce790c9410a3be05700fd549da8387a214ecad63eebe1fee09540b6
|
data/.pryrc
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
if defined?(PryByebug)
|
2
4
|
Pry.commands.alias_command 'c', 'continue'
|
3
5
|
Pry.commands.alias_command 's', 'step'
|
@@ -6,6 +8,6 @@ if defined?(PryByebug)
|
|
6
8
|
end
|
7
9
|
|
8
10
|
# Hit Enter to repeat last command
|
9
|
-
Pry::Commands.command /^$/,
|
11
|
+
Pry::Commands.command /^$/, 'repeat last command' do
|
10
12
|
_pry_.run_command Pry.history.to_a.last
|
11
13
|
end
|
data/Gemfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
6
|
|
5
7
|
# Specify your gem's dependencies in require_bench.gemspec
|
6
8
|
gemspec
|
data/README.md
CHANGED
@@ -6,6 +6,8 @@ Knowing the last file that was successfully "required" by Ruby can be helpful in
|
|
6
6
|
|
7
7
|
This is an extraction of a debugging tool that I have copy/pasted into many projects over the years, and it is now time to set it free.
|
8
8
|
|
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
|
+
|
9
11
|
| Project | RequireBench |
|
10
12
|
|------------------------ | ----------------------- |
|
11
13
|
| gem name | [require_bench](https://rubygems.org/gems/require_bench) |
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'require_bench'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "require_bench"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start(__FILE__)
|
data/lib/require_bench.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# STD Libs
|
2
4
|
require 'benchmark'
|
3
5
|
|
4
6
|
# This Gem
|
5
|
-
require
|
7
|
+
require 'require_bench/version'
|
6
8
|
|
7
9
|
module RequireBench
|
8
10
|
TIMINGS = Hash.new { |h, k| h[k] = 0.0 }
|
@@ -34,9 +36,9 @@ if ENV['REQUIRE_BENCH'] == 'true'
|
|
34
36
|
when Regexp then
|
35
37
|
skips
|
36
38
|
when Array then
|
37
|
-
Regexp.new(skips.map{ |x| Regexp.escape(x) }.join('|'))
|
39
|
+
Regexp.new(skips.map { |x| Regexp.escape(x) }.join('|'))
|
38
40
|
when String then
|
39
|
-
Regexp.new(skips.split(',').map{ |x| Regexp.escape(x) }.join('|'))
|
41
|
+
Regexp.new(skips.split(',').map { |x| Regexp.escape(x) }.join('|'))
|
40
42
|
end
|
41
43
|
puts "[RequireBench] Setting REQUIRE_BENCH_SKIP_PATTERN to #{skip_pattern}"
|
42
44
|
ENV['REQUIRE_BENCH_SKIP_PATTERN'] = skip_pattern
|
data/lib/require_bench/tasks.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# NOTE: Gem is only active if REQUIRE_BENCH=true is set in shell
|
2
4
|
|
3
5
|
# require 'require_bench/tasks'
|
@@ -20,12 +22,12 @@ namespace :require_bench do
|
|
20
22
|
puts '=========='
|
21
23
|
printf("%10f %s\n", tot, 'TOTAL')
|
22
24
|
else
|
23
|
-
puts %
|
25
|
+
puts %(
|
24
26
|
require_bench did not track any requires, because it was required too late.
|
25
27
|
Require in Rakefile, as follows
|
26
28
|
require 'bundler/setup'
|
27
29
|
require 'require_bench/tasks'
|
28
|
-
|
30
|
+
)
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
data/require_bench.gemspec
CHANGED
@@ -1,28 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
5
|
+
require 'require_bench/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'require_bench'
|
8
9
|
spec.version = RequireBench::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
10
|
+
spec.authors = ['Peter Boling']
|
11
|
+
spec.email = ['peter.boling@gmail.com']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
13
|
+
spec.summary = 'Discover bootstrapping issues in Ruby by benchmarking "Kernel.require"'
|
14
|
+
spec.description = 'Ruby app loading slowly, or never? Discover bootstrapping issues in Ruby by benchmarking "Kernel.require"'
|
15
|
+
spec.homepage = 'https://github.com/pboling/require_bench'
|
15
16
|
|
16
17
|
# Specify which files should be added to the gem when it is released.
|
17
18
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
-
spec.files = Dir.chdir(File.expand_path(
|
19
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
19
20
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
21
|
end
|
21
|
-
spec.bindir =
|
22
|
+
spec.bindir = 'exe'
|
22
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
-
spec.require_paths = [
|
24
|
+
spec.require_paths = ['lib']
|
25
|
+
spec.license = 'MIT'
|
24
26
|
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: require_bench
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Boling
|
@@ -78,7 +78,8 @@ files:
|
|
78
78
|
- lib/require_bench/version.rb
|
79
79
|
- require_bench.gemspec
|
80
80
|
homepage: https://github.com/pboling/require_bench
|
81
|
-
licenses:
|
81
|
+
licenses:
|
82
|
+
- MIT
|
82
83
|
metadata: {}
|
83
84
|
post_install_message:
|
84
85
|
rdoc_options: []
|