faster_rubygems 0.0.1
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.
- data/README +58 -0
- data/Rakefile +15 -0
- data/VERSION +1 -0
- data/examples/require_fast_start.rb +3 -0
- data/examples/require_rubygems_normal.rb +3 -0
- data/ext/mkrf_conf.rb +11 -0
- data/install.rb +12 -0
- data/lib/frubygems.rb +1 -0
- data/lib/rubygems_fast.rb +58 -0
- metadata +68 -0
data/README
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
A helper to dramatically speedup the time it takes to load rubygems
|
2
|
+
|
3
|
+
i.e. "require 'rubygems'" no longer has to sap valuable time from your life.
|
4
|
+
|
5
|
+
inspired by a request from Yehuda Katz [1] and 1.9's fast gem_prelude.
|
6
|
+
|
7
|
+
Speed difference (windows box, lots of gem):
|
8
|
+
|
9
|
+
$ time ruby examples/require_rubygems_normal.rb
|
10
|
+
|
11
|
+
real 0m1.109s
|
12
|
+
|
13
|
+
$ time ruby examples/require_fast_start.rb
|
14
|
+
|
15
|
+
real 0m0.500s
|
16
|
+
|
17
|
+
Yea! Finally ruby script startup times that don't spend forever just reloading gem paths.
|
18
|
+
|
19
|
+
It acts about the same as gem_prelude (prelude is 1.9 only currently) -- adds the paths of the highest version of each gem into your load path so they're ready to be required.
|
20
|
+
|
21
|
+
== installation ==
|
22
|
+
|
23
|
+
git clone git://github.com/rdp/faster_rubygems.git
|
24
|
+
ruby faster_rubygems/install.rb # done
|
25
|
+
|
26
|
+
== usage ==
|
27
|
+
require 'frubygems'
|
28
|
+
or
|
29
|
+
require 'rubygemsf'
|
30
|
+
|
31
|
+
(both do the same thing).
|
32
|
+
|
33
|
+
If you were really clever I suppose you could figure out how to override the default rubygem behavior to do this, always :)
|
34
|
+
|
35
|
+
== Speed differences ==
|
36
|
+
|
37
|
+
For those interested, speed difference example on linux (250 gems):
|
38
|
+
$ time ruby examples/require_rubygems_normal.rb
|
39
|
+
ruby examples/require_rubygems_normal.rb 0.57s user 0.05s system 85%
|
40
|
+
cpu 0.726 total
|
41
|
+
|
42
|
+
$ time ruby examples/require_fast_start.rb
|
43
|
+
ruby examples/require_fast_start.rb 0.04s user 0.02s system 46% cpu
|
44
|
+
0.121 total
|
45
|
+
|
46
|
+
Note also that a few non conforming gems require the use of require 'rubygems' no matter what (they're pretty rare, though--you probably won't run into them, and I'm not aware of any).
|
47
|
+
|
48
|
+
Note: you don't need this for ruby 1.9, which already preloads via gem_prelude, but it won't hurt to use it in 1.9--it defaults to a no-op, so doesn't hurt.
|
49
|
+
|
50
|
+
Related projects:
|
51
|
+
|
52
|
+
http://github.com/fabien/minigems/tree/master
|
53
|
+
1.9's gem_prelude
|
54
|
+
http://www.ruby-forum.com/topic/191673
|
55
|
+
|
56
|
+
Author may be reached via github rogerdpack
|
57
|
+
|
58
|
+
[1] http://rubyforge.org/tracker/index.php?func=detail&aid=21288&group_id=126&atid=578
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
raise 'do it by hand'
|
4
|
+
Jeweler::Tasks.new do |gemspec|
|
5
|
+
gemspec.name = "faster_rubygems"
|
6
|
+
gemspec.summary = "faster gem loading"
|
7
|
+
# gemspec.description = "Describe your gem"
|
8
|
+
# gemspec.email = "josh@technicalpickles.com"
|
9
|
+
# gemspec.homepage = "http://github.com/technicalpickles/the-perfect-gem"
|
10
|
+
# gemspec.description = "TODO"
|
11
|
+
# gemspec.authors = ["Josh Nichols"]
|
12
|
+
end
|
13
|
+
rescue LoadError
|
14
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
15
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/ext/mkrf_conf.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
puts 'in mkrf'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'sane'
|
4
|
+
#require '_dbg'
|
5
|
+
puts File.dirname(__FILE__)
|
6
|
+
a = File.expand_path(File.dirname(__FILE__)) + "/../install.rb" # install it for them
|
7
|
+
load a
|
8
|
+
|
9
|
+
f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w") # create dummy rakefile to indicate success
|
10
|
+
f.write("task :default\n")
|
11
|
+
f.close
|
data/install.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'rbconfig'
|
3
|
+
|
4
|
+
Dir.chdir File.dirname(__FILE__) + '/lib' do
|
5
|
+
for file in Dir['*.rb'] do
|
6
|
+
FileUtils.cp file, Config::CONFIG['sitelibdir'] + '/' + file
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'frubygems' # test it out now :P
|
11
|
+
|
12
|
+
puts 'Installed--thank you for trying out -- require \'frubygems\''
|
data/lib/frubygems.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rubygems_fast'
|
@@ -0,0 +1,58 @@
|
|
1
|
+
if RUBY_VERSION < '1.9'
|
2
|
+
require 'rbconfig'
|
3
|
+
|
4
|
+
gem_paths = []
|
5
|
+
gem_paths << Config::CONFIG['libdir'] + '/ruby/gems/' + RUBY_VERSION[0..2] + '/gems'
|
6
|
+
|
7
|
+
# handle ~/.gem
|
8
|
+
gem_paths << File.expand_path('~') + '/.gem/ruby/' + RUBY_VERSION[0..2] + '/gems'
|
9
|
+
|
10
|
+
# handle ENV['GEM_PATH'] if it exists
|
11
|
+
gem_paths << ENV['GEM_PATH'].split(':').select{|path| path + '/.gems'} if ENV['GEM_PATH'] # TODO should this override or supplement?
|
12
|
+
|
13
|
+
# TODO
|
14
|
+
# spec: should find highest version of files
|
15
|
+
# spec: with multiple paths should find all files :P
|
16
|
+
|
17
|
+
all_gems = []
|
18
|
+
|
19
|
+
for gem_path in gem_paths.flatten do
|
20
|
+
|
21
|
+
all_gems << Dir.glob(gem_path + '/*')
|
22
|
+
|
23
|
+
end
|
24
|
+
all_gems.flatten!.sort!.reverse!
|
25
|
+
|
26
|
+
already_loaded_gems = {}
|
27
|
+
|
28
|
+
for gem in all_gems do
|
29
|
+
|
30
|
+
version = gem.split('-')[-1]
|
31
|
+
if version =~ /\d+\.\d+\.\d+/
|
32
|
+
name = gem.split('-')[0..-2]
|
33
|
+
else
|
34
|
+
gem =~ /(.*)(\d+\.\d+\.\d+).*$/ # like abc-1.2.3-mswin32-60 or what not
|
35
|
+
version = $2
|
36
|
+
name = $1
|
37
|
+
next unless version # a few oddities like rbfind-1.1
|
38
|
+
end
|
39
|
+
|
40
|
+
if(!already_loaded_gems[name])
|
41
|
+
already_loaded_gems[name] = true
|
42
|
+
if File.directory? gem + '/lib'
|
43
|
+
$: << gem + '/lib'
|
44
|
+
else
|
45
|
+
# unfortunately a few gems load from, say gem/something_not_lib/gemname.rb
|
46
|
+
for dir in Dir.glob(gem + '/*') do
|
47
|
+
if File.directory? dir
|
48
|
+
$: << dir
|
49
|
+
# if anybody wants anything lower than that, let me know
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
else
|
57
|
+
# not needed in 1.9, which by default loads gem_prelude
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: faster_rubygems
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors: []
|
7
|
+
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-29 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email:
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions:
|
21
|
+
- ext/mkrf_conf.rb
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
files:
|
25
|
+
- README
|
26
|
+
- Rakefile
|
27
|
+
- VERSION
|
28
|
+
- examples/require_fast_start.rb
|
29
|
+
- examples/require_rubygems_normal.rb
|
30
|
+
- ext/mkrf_conf.rb
|
31
|
+
- install.rb
|
32
|
+
- lib/frubygems.rb
|
33
|
+
- lib/rubygems_fast.rb
|
34
|
+
has_rdoc: true
|
35
|
+
homepage:
|
36
|
+
licenses: []
|
37
|
+
|
38
|
+
post_install_message: |+
|
39
|
+
|
40
|
+
|
41
|
+
installed! require 'frubygems' now
|
42
|
+
|
43
|
+
rdoc_options:
|
44
|
+
- --charset=UTF-8
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
version:
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
version:
|
59
|
+
requirements: []
|
60
|
+
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 1.3.5
|
63
|
+
signing_key:
|
64
|
+
specification_version: 3
|
65
|
+
summary: faster gem loading
|
66
|
+
test_files:
|
67
|
+
- examples/require_fast_start.rb
|
68
|
+
- examples/require_rubygems_normal.rb
|