Skip to content

Instantly share code, notes, and snippets.

@miyucy
Created December 26, 2015 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miyucy/70876be6570beccc39f0 to your computer and use it in GitHub Desktop.
Save miyucy/70876be6570beccc39f0 to your computer and use it in GitHub Desktop.
require 'bundler'
Bundler.require
require 'json'
require 'zlib'
require 'base64'
require 'rbconfig'
ext = '.' + RbConfig::CONFIG['DLEXT']
iseqs = {}
$LOADED_FEATURES
.reject { |loaded_feature| loaded_feature.end_with? ext }
.select { |loaded_feature| File.exist? loaded_feature }.each { |loaded_feature|
iseqs[loaded_feature] = Base64.strict_encode64 RubyVM::InstructionSequence.compile_file(loaded_feature).to_binary
}
File.binwrite 'packed.iseqs', JSON.dump(iseqs)
File.binwrite 'packed.iseqs.gz', Zlib.deflate(JSON.dump(iseqs))
require 'json'
require 'zlib'
require 'base64'
ISEQZ = JSON.parse(Zlib.inflate(File.binread 'packed.iseqs.gz')).map { |k, v|
[k, RubyVM::InstructionSequence.load_from_binary(Base64.strict_decode64(v))]
}.to_h
class RubyVM::InstructionSequence
def self.load_iseq(fname)
#puts fname
ISEQZ.delete fname
end
end
require 'bundler'
Bundler.require
require 'digest/sha1'
puts Digest::SHA1.hexdigest $LOADED_FEATURES.sort.join(',')
require 'json'
require 'zlib'
require 'base64'
require 'bundler'
Bundler.require
require 'digest/sha1'
puts Digest::SHA1.hexdigest $LOADED_FEATURES.sort.join(',')
source 'https://rubygems.org'
gem 'rails', '~> 4.2.0'
gem 'pry-byebug'
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.5)
actionpack (= 4.2.5)
actionview (= 4.2.5)
activejob (= 4.2.5)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.5)
actionview (= 4.2.5)
activesupport (= 4.2.5)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.5)
activesupport (= 4.2.5)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.5)
activesupport (= 4.2.5)
globalid (>= 0.3.0)
activemodel (4.2.5)
activesupport (= 4.2.5)
builder (~> 3.1)
activerecord (4.2.5)
activemodel (= 4.2.5)
activesupport (= 4.2.5)
arel (~> 6.0)
activesupport (4.2.5)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
builder (3.2.2)
byebug (8.2.1)
coderay (1.1.0)
concurrent-ruby (1.0.0)
erubis (2.7.0)
globalid (0.3.6)
activesupport (>= 4.1.0)
i18n (0.7.0)
json (1.8.3)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
method_source (0.8.2)
mime-types (2.99)
mini_portile2 (2.0.0)
minitest (5.8.3)
nokogiri (1.6.7.1)
mini_portile2 (~> 2.0.0.rc2)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-byebug (3.3.0)
byebug (~> 8.0)
pry (~> 0.10)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.5)
actionmailer (= 4.2.5)
actionpack (= 4.2.5)
actionview (= 4.2.5)
activejob (= 4.2.5)
activemodel (= 4.2.5)
activerecord (= 4.2.5)
activesupport (= 4.2.5)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.5)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
railties (4.2.5)
actionpack (= 4.2.5)
activesupport (= 4.2.5)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
slop (3.6.0)
sprockets (3.5.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.0.0)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (0.19.1)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
PLATFORMS
ruby
DEPENDENCIES
pry-byebug
rails (~> 4.2.0)
BUNDLED WITH
1.11.2
∴ ruby c.rb
∴ ll
total 33128
-rw-r--r-- 1 miyucy staff 72 12 26 02:27 Gemfile
-rw-r--r-- 1 miyucy staff 2811 12 26 02:28 Gemfile.lock
-rw-r--r-- 1 miyucy staff 2244 12 26 09:15 c.rb
-rw-r--r-- 1 miyucy staff 440 12 26 09:17 d.rb
-rw-r--r-- 1 miyucy staff 164 12 26 09:18 e.rb
-rw-r--r-- 1 miyucy staff 14409118 12 26 09:20 packed.iseqs
-rw-r--r-- 1 miyucy staff 2522469 12 26 09:20 packed.iseqs.gz
∴ time ruby e.rb
1ac18b57f8fe694eba31291d609ef380e979d083
ruby e.rb 0.86s user 0.21s system 52% cpu 2.055 total
∴ time ruby e.rb
1ac18b57f8fe694eba31291d609ef380e979d083
ruby e.rb 0.87s user 0.21s system 52% cpu 2.067 total
∴ time ruby e.rb
1ac18b57f8fe694eba31291d609ef380e979d083
ruby e.rb 0.87s user 0.21s system 52% cpu 2.072 total
∴ time ruby d.rb
1ac18b57f8fe694eba31291d609ef380e979d083
ruby d.rb 0.72s user 0.20s system 48% cpu 1.909 total
∴ time ruby d.rb
1ac18b57f8fe694eba31291d609ef380e979d083
ruby d.rb 0.71s user 0.20s system 48% cpu 1.891 total
∴ time ruby d.rb
1ac18b57f8fe694eba31291d609ef380e979d083
ruby d.rb 0.71s user 0.20s system 48% cpu 1.905 total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment