bumbler 0.6.0 → 0.9.0
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 +4 -4
- data/README.md +1 -1
- data/bin/bumbler +4 -2
- data/lib/bumbler/bundler.rb +1 -1
- data/lib/bumbler/hooks.rb +38 -16
- data/lib/bumbler/progress.rb +4 -1
- data/lib/bumbler/track_initializers.rb +14 -10
- data/lib/bumbler/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ad7fe2ebf27b55813bffb1ba59a966c14f9c3eda4b9df33d568754072549e1e
|
4
|
+
data.tar.gz: e64f75c85c1b996dd5cdfc2ddc1fc2d318e3809464788758578a2799864e6f7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75412e45f8d0764be03b8a7c657d477cc51be29b25ff74b614dfacac3440b2e3d0d2ed8442af3de0da0288cc7cb982a883889e2571edb284a281ced58408c9dd
|
7
|
+
data.tar.gz: d1c438a7d9f168ab285c16c53a10ffbe505a6b312d6667b2a201d8e6d4049a25576809cc781991593656380bfa6df75aaa305343c1cd3ca1d9b7c5e92d7b2cf3
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Find slow loading gems in your [Bundler](http://gembundler.com/)-based projects!
|
|
6
6
|
Bumbler tracks how long the main require of each gem takes,
|
7
7
|
for example with `gem 'bar'` it tracks `require 'bar'`. If the gem name and the require name are different,
|
8
8
|
add `require:` manually for correct time tracking, for example `gem 'bar-foo', require: 'bar_foo'`.
|
9
|
-
This
|
9
|
+
This require tracking can sometimes lead to false positives, because of dependencies,
|
10
10
|
for example `foo` requires `rails` which leads to `foo` being marked as slow.
|
11
11
|
|
12
12
|
For rails projects it loads `config/environment.rb`, for all others it runs `Bundler.require *Bundler.groups`.
|
data/bin/bumbler
CHANGED
@@ -21,7 +21,9 @@ OptionParser.new do |parser|
|
|
21
21
|
|
22
22
|
Options:
|
23
23
|
BANNER
|
24
|
-
parser.on("-t", "--threshold MILLISECONDS", Integer, "Threshold in ms to be listed as slow")
|
24
|
+
parser.on("-t", "--threshold MILLISECONDS", Integer, "Threshold in ms to be listed as slow") do |t|
|
25
|
+
options[:threshold] = t
|
26
|
+
end
|
25
27
|
parser.on("--initializers", "Show load time of initializers") { options[:initializers] = true }
|
26
28
|
parser.on("--all", "Show all load times") { options[:all] = true }
|
27
29
|
parser.on("-h", "--help", "Show this.") { puts parser; exit }
|
@@ -37,7 +39,7 @@ if options[:initializers]
|
|
37
39
|
add_load_path.call # bundler kicks us out
|
38
40
|
require 'bumbler/track_initializers'
|
39
41
|
require './config/environment'
|
40
|
-
elsif File.exist?('./config/environment')
|
42
|
+
elsif File.exist?('./config/environment.rb')
|
41
43
|
require 'bumbler/go'
|
42
44
|
require './config/environment'
|
43
45
|
add_load_path.call # bundler kicks us out
|
data/lib/bumbler/bundler.rb
CHANGED
data/lib/bumbler/hooks.rb
CHANGED
@@ -13,9 +13,29 @@ module Bumbler
|
|
13
13
|
|
14
14
|
# Inject our custom handling of require into the Kernel.
|
15
15
|
def hook_require!
|
16
|
-
|
16
|
+
hook_instance_require!
|
17
|
+
hook_singleton_require!
|
18
|
+
end
|
19
|
+
|
20
|
+
def hook_instance_require!
|
21
|
+
@hooking_instance_require = true
|
22
|
+
|
23
|
+
::Kernel.module_eval do
|
24
|
+
orig_instance_require = instance_method(:require)
|
25
|
+
define_method(:require) do |path, *args|
|
26
|
+
::Bumbler::Hooks.handle_require(path) do
|
27
|
+
orig_instance_require.bind(self).call(path, *args)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
private :require
|
31
|
+
end
|
32
|
+
|
33
|
+
@hooking_instance_require = nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def hook_singleton_require!
|
37
|
+
@hooking_singleton_require = true
|
17
38
|
|
18
|
-
# There are two independent require methods. Joy!
|
19
39
|
::Kernel.module_eval do
|
20
40
|
class << self
|
21
41
|
orig_public_require = Kernel.public_method(:require)
|
@@ -25,33 +45,35 @@ module Bumbler
|
|
25
45
|
end
|
26
46
|
end
|
27
47
|
end
|
28
|
-
|
29
|
-
orig_instance_require = instance_method(:require)
|
30
|
-
define_method(:require) do |path, *args|
|
31
|
-
::Bumbler::Hooks.handle_require(path) do
|
32
|
-
orig_instance_require.bind(self).call(path, *args)
|
33
|
-
end
|
34
|
-
end
|
35
48
|
end
|
36
49
|
|
37
|
-
@
|
50
|
+
@hooking_singleton_require = nil
|
38
51
|
end
|
39
52
|
|
40
53
|
# Even better: Other gems hook require as well. The instance method one at least.
|
41
54
|
def watch_require!
|
42
55
|
::Kernel.module_eval do
|
43
56
|
# It isn't previously defined in Kernel. This could be a bit dangerous, though.
|
44
|
-
def self.method_added(method_name, *_args)
|
45
|
-
if method_name == :require &&
|
46
|
-
|
47
|
-
|
57
|
+
def self.method_added(method_name, *_args) # rubocop:disable Lint/MissingSuper
|
58
|
+
if method_name == :require && !Bumbler::Hooks.hooking_instance_require?
|
59
|
+
::Bumbler::Hooks.hook_instance_require!
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.singleton_method_added(method_name, *_args) # rubocop:disable Lint/MissingSuper
|
64
|
+
if method_name == :require && !Bumbler::Hooks.hooking_singleton_require?
|
65
|
+
::Bumbler::Hooks.hook_singleton_require!
|
48
66
|
end
|
49
67
|
end
|
50
68
|
end
|
51
69
|
end
|
52
70
|
|
53
|
-
def
|
54
|
-
@
|
71
|
+
def hooking_instance_require?
|
72
|
+
@hooking_instance_require
|
73
|
+
end
|
74
|
+
|
75
|
+
def hooking_singleton_require?
|
76
|
+
@hooking_singleton_require
|
55
77
|
end
|
56
78
|
|
57
79
|
# Actually do something about a require here.
|
data/lib/bumbler/progress.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# TODO: replace with ruby-progressbar dependency
|
3
|
+
require 'io/console'
|
4
|
+
|
3
5
|
module Bumbler
|
4
6
|
module Progress
|
5
7
|
@item_count = 0
|
@@ -36,7 +38,8 @@ module Bumbler
|
|
36
38
|
end
|
37
39
|
|
38
40
|
def tty_width
|
39
|
-
|
41
|
+
# console_winsize: https://github.com/ruby/ruby/blob/f27eb8148f5a72bbacfebfecc7de9305471bb5c9/ext/io/console/console.c#L796
|
42
|
+
IO.console.winsize[1]
|
40
43
|
end
|
41
44
|
|
42
45
|
def bar(width)
|
@@ -1,14 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
Rails::Engine.prepend(
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
Rails::Engine.prepend(
|
3
|
+
Module.new do
|
4
|
+
def load(file, *)
|
5
|
+
initializer = file.sub(Rails.root.to_s, ".")
|
6
|
+
Bumbler::Hooks.benchmark(initializer) { super }.last
|
7
|
+
end
|
6
8
|
end
|
7
|
-
|
9
|
+
)
|
8
10
|
|
9
|
-
Rails::Initializable::Initializer.prepend(
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
Rails::Initializable::Initializer.prepend(
|
12
|
+
Module.new do
|
13
|
+
def run(*)
|
14
|
+
name = (@name.is_a?(Symbol) ? @name.inspect : @name)
|
15
|
+
Bumbler::Hooks.benchmark(name) { super }.last
|
16
|
+
end
|
13
17
|
end
|
14
|
-
|
18
|
+
)
|
data/lib/bumbler/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bumbler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian MacLeod
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bump
|
@@ -97,14 +97,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
97
|
requirements:
|
98
98
|
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
|
-
version: 2.
|
100
|
+
version: 2.7.0
|
101
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
103
|
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
|
-
rubygems_version: 3.
|
107
|
+
rubygems_version: 3.1.6
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Find slowly loading gems for your Bundler-based projects
|