fastup 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastup.rb +26 -24
- data/test/app/boot.rb +1 -1
- data/test/app/counts.rb +15 -0
- data/test/fastup_test.rb +14 -11
- 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: ed16ec41e53affe880060f5a68b2be13f40dda18fed6df09b7fef562aeeffe6c
|
4
|
+
data.tar.gz: 53dcd47645e9b560a96c071f3e8445a5cebbdd4bf6083288ccf56a4c721603d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93f1e6f5ec39d3708850e9b7af7fa4e3dd3eb252845680fb2678855281a04476e99767b8fc4dc1d933918281f6029c08a1d508caa53d06633fefa850e23896d1
|
7
|
+
data.tar.gz: a1ea36d4c1ce7cdb15db3fd72afa64cc5b9ebb1fde8aec5709cecd8a552ecd110620d70d56fd4dd02b536fd75e1d4df5fbbf44e9aa94e913a7ad80ee0e7388c1
|
data/lib/fastup.rb
CHANGED
@@ -1,35 +1,37 @@
|
|
1
1
|
module Fastup
|
2
|
-
|
2
|
+
def self.require(name, original_require)
|
3
|
+
path = @suffixes.map{ |s| @sp.lookup(name.to_s + s) rescue nil }.find do |p|
|
4
|
+
p && File.file?(p)
|
5
|
+
end
|
3
6
|
|
4
|
-
|
5
|
-
|
6
|
-
sp = SearchPath.new($LOAD_PATH)
|
7
|
-
suffixes = Gem.suffixes.lazy
|
7
|
+
# require the absolute path if found, otherwise fallback to original name
|
8
|
+
ret = original_require.call(path || name)
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
if ret && ENV['FASTUP_DEBUG']
|
11
|
+
if path
|
12
|
+
warn "fastup: loaded #{name} => #{path}"
|
13
|
+
else
|
14
|
+
warn "fastup: super #{name}"
|
15
|
+
end
|
16
|
+
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
+
ret
|
19
|
+
end
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
else
|
23
|
-
warn "fastup: super #{name}"
|
24
|
-
end
|
25
|
-
end
|
21
|
+
def self.apply!
|
22
|
+
@sp = SearchPath.new($LOAD_PATH)
|
23
|
+
@suffixes = Gem.suffixes.lazy
|
26
24
|
|
27
|
-
|
28
|
-
|
25
|
+
instance_require = Kernel.instance_method(:require)
|
26
|
+
require = Kernel.method(:require)
|
27
|
+
|
28
|
+
Kernel.send(:define_method, :require) do |name|
|
29
|
+
Fastup.require(name, instance_require.bind(self))
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
Kernel.singleton_class.send(:define_method, :require) do |name|
|
33
|
+
Fastup.require(name, require)
|
34
|
+
end
|
33
35
|
end
|
34
36
|
|
35
37
|
module XFile
|
data/test/app/boot.rb
CHANGED
data/test/app/counts.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'fastup/autoapply' if ENV['USE_FASTUP']
|
5
|
+
|
6
|
+
total = Benchmark.measure{ Bundler.require }.total
|
7
|
+
|
8
|
+
puts ['gems_count', 'load_path_size', 'loaded_features_size', 'time'].join("\t") if ENV['PRINT_HEADER']
|
9
|
+
|
10
|
+
puts "%d\t%d\t%d\t%.5f" % [
|
11
|
+
ENV['GEMS_COUNT'].to_i,
|
12
|
+
$LOAD_PATH.size,
|
13
|
+
$LOADED_FEATURES.size,
|
14
|
+
total,
|
15
|
+
]
|
data/test/fastup_test.rb
CHANGED
@@ -1,35 +1,38 @@
|
|
1
1
|
require 'benchmark'
|
2
|
+
require 'open3'
|
2
3
|
require 'tmpdir'
|
3
4
|
|
4
5
|
require 'test_helper'
|
5
6
|
|
6
7
|
module Fastup
|
7
8
|
class TestAppBoot < Minitest::Test
|
9
|
+
def capture(*args)
|
10
|
+
out, status = Open3.capture2e(*args)
|
11
|
+
raise "#{args} exited with error:\n#{out}" unless status.success?
|
12
|
+
out
|
13
|
+
end
|
14
|
+
|
8
15
|
tag :slow
|
9
16
|
def test_app_boot
|
10
17
|
results = {}
|
11
18
|
|
12
19
|
Bundler.with_original_env do
|
13
20
|
Dir.chdir(File.expand_path('../app', __FILE__)) do
|
14
|
-
results[:setup] =
|
15
|
-
|
21
|
+
results[:setup] = capture "bundle --quiet"
|
22
|
+
|
23
|
+
filter = ->(line) do
|
24
|
+
line =~ /^feature:/ && line !~ %r{/lib/fastup}
|
25
|
+
end
|
16
26
|
|
17
27
|
results[:total_fastup] = Benchmark.measure {
|
18
|
-
|
19
|
-
raise "fastup exited with error: #{out}" unless $?.success?
|
20
|
-
results[:output_fastup] = out.lines.reject{ |p| p =~ %r{/lib/fastup} }
|
28
|
+
results[:output_fastup] = capture("USE_FASTUP=1 BUNDLE_FROZEN=true bundle exec ruby boot.rb").lines.select(&filter)
|
21
29
|
}
|
22
30
|
results[:total_nofastup] = Benchmark.measure {
|
23
|
-
|
24
|
-
raise "nofastup exited with error: #{out}" unless $?.success?
|
25
|
-
results[:output_nofastup] = out.lines.reject{ |p| p =~ %r{/lib/fastup} }
|
31
|
+
results[:output_nofastup] = capture("BUNDLE_FROZEN=true bundle exec ruby boot.rb").lines.select(&filter)
|
26
32
|
}
|
27
33
|
end
|
28
34
|
end
|
29
35
|
|
30
|
-
results[:output_fastup].reject!{ |p| p =~ %r{fastup/lib/fastup} }
|
31
|
-
results[:output_nofastup].reject!{ |p| p =~ %r{fastup/lib/fastup} }
|
32
|
-
|
33
36
|
warn("\nfastup: %.2f nofastup: %.2f" % [results[:total_fastup].total, results[:total_nofastup].total])
|
34
37
|
|
35
38
|
assert results[:total_fastup].total < results[:total_nofastup].total,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Mahoney
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- lib/fastup.rb
|
95
95
|
- lib/fastup/autoapply.rb
|
96
96
|
- test/app/boot.rb
|
97
|
+
- test/app/counts.rb
|
97
98
|
- test/fastup_test.rb
|
98
99
|
- test/test_helper.rb
|
99
100
|
homepage: https://github.com/raisemarketplace/fastup
|