Skip to content

Instantly share code, notes, and snippets.

@calavera
Created November 24, 2009 14:31
Show Gist options
  • Save calavera/241900 to your computer and use it in GitHub Desktop.
Save calavera/241900 to your computer and use it in GitHub Desktop.
david@david-mirai ~/dev/jruby$ bin/jruby -b -e 'require "yaml"'
-> builtin/core_ext/symbol
<- builtin/core_ext/symbol - 39ms
-> enumerator
<- enumerator - 3ms
-> yaml
-> stringio
<- stringio - 9ms
-> yaml/compat
<- yaml/compat - 15ms
-> yaml/error
<- yaml/error - 2ms
-> yaml/yecht
-> yecht
<- yecht - 117ms
-> yaml/basenode
-> yaml/ypath
<- yaml/ypath - 5ms
<- yaml/basenode - 20ms
<- yaml/yecht - 147ms
-> yaml/tag
<- yaml/tag - 7ms
-> yaml/stream
<- yaml/stream - 1ms
-> yaml/constants
<- yaml/constants - 3ms
-> yaml/rubytypes
-> date
-> date
<- date - 0ms
<- date - 2ms
-> yaml/compat
<- yaml/compat - 0ms
<- yaml/rubytypes - 51ms
-> yaml/types
-> yaml/compat
<- yaml/compat - 0ms
<- yaml/types - 10ms
<- yaml - 296ms
Runtime: 313 ms
From a83f8402d598fad87b600e4a2419ee5f6fb82c1d Mon Sep 17 00:00:00 2001
From: David Calavera <[email protected]>
Date: Tue, 24 Nov 2009 15:29:33 +0100
Subject: [PATCH] [PATCH] fixes JRUBY-4268: speed-up yaml/yecht loading
---
src/org/jruby/Ruby.java | 2 ++
src/org/jruby/RubyJRuby.java | 6 ++++++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/org/jruby/Ruby.java b/src/org/jruby/Ruby.java
index 3b09120..b537638 100644
--- a/src/org/jruby/Ruby.java
+++ b/src/org/jruby/Ruby.java
@@ -1396,6 +1396,8 @@ public final class Ruby {
runtime.getLoadService().require("jruby/openssl/stub");
}
});
+
+ addLazyBuiltin("date.rb", "date", "org.jruby.RubyJRuby$DateLibrary");
String[] builtins = {"yaml",
"yaml/yecht", "yaml/baseemitter", "yaml/basenode",
diff --git a/src/org/jruby/RubyJRuby.java b/src/org/jruby/RubyJRuby.java
index 0511a95..f0b9c64 100644
--- a/src/org/jruby/RubyJRuby.java
+++ b/src/org/jruby/RubyJRuby.java
@@ -155,6 +155,12 @@ public class RubyJRuby {
}
}
+ public static class DateLibrary implements Library {
+ public void load(Ruby runtime, boolean wrap) throws IOException {
+ runtime.getLoadService().lockAndRequire("date");
+ }
+ }
+
/**
* Utilities library for all those methods that don't need the full 'java' library
* to be loaded. This is done mostly for performance reasons. For example, for those
--
1.6.0.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment