Skip to content

Instantly share code, notes, and snippets.

View shirosaki's full-sized avatar

Hiroshi Shirosaki shirosaki

View GitHub Profile
@shirosaki
shirosaki / hash_bench.rb
Created December 29, 2011 14:21
Hash size distribution
#!/usr/bin/env ruby
number = 100_000
(1..10).each do |hash_size|
number /= 10 if hash_size == 7
number.times do
h = {}
hash_size.times do |i|
h[i] = true
h[i]
diff --git a/common.mk b/common.mk
index 124cde3..fb8f5e7 100644
--- a/common.mk
+++ b/common.mk
@@ -24,7 +24,7 @@ EXTCONF = extconf.rb
RBCONFIG = ./.rbconfig.time
LIBRUBY_EXTS = ./.libruby-with-ext.time
REVISION_H = ./.revision.time
-PLATFORM_D = ./$(PLATFORM)/.time
+PLATFORM_D = $(CURDIR)/$(PLATFORM)
diff --git a/common.mk b/common.mk
index de22d39..774f83f 100644
--- a/common.mk
+++ b/common.mk
@@ -429,6 +429,7 @@ clean-local:: PHONY
@$(RM) $(OBJS) $(MINIOBJS) $(MAINOBJ) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY) $(LIBRUBY_ALIASES)
@$(RM) $(PROGRAM) $(WPROGRAM) miniruby$(EXEEXT) dmyext.$(OBJEXT) $(ARCHFILE) .*.time
@$(RM) y.tab.c y.output encdb.h transdb.h prelude.c config.log rbconfig.rb $(ruby_pc)
+ -$(Q)$(RMDIR) $(PLATFORM) 2> /dev/null || true
clean-ext:: PHONY
diff --git a/Makefile.in b/Makefile.in
index a3040b6..83d525b 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -12,6 +12,7 @@ NULL = /dev/null
srcdir = @srcdir@
top_srcdir = $(srcdir)
hdrdir = $(srcdir)/include
+PLATFORM = @PLATFORM@
@shirosaki
shirosaki / bench.txt
Created December 26, 2011 06:29
benchmark of hash optimization
On WinXP with gcc version 4.5.2 (tdm-1)
# hash_bench.rb - about 14 % improvement
h = {}
3000000.times do |i|
h[i] = true
end
# hash2_bench.rb - about 50 % improvement
1000000.times do |i|
@shirosaki
shirosaki / bar_chart.rb
Created December 24, 2011 07:01
Timing chart
#!/usr/bin/env ruby
#
# https://github.com/mattetti/googlecharts
# http://mattetti.github.com/googlecharts/
#
# Install:
# gem install googlecharts
#
# GitHub Flavord Markdown:
# ![chart title](http://chart.apis.google.com/chart?...)
CPU: Intel Core 2 Duo 6600 2.40GHz
RAM: 4 GB
HDD: On Ramdisk 1.1GB using ImDisk
AV: Off
OS: Windows XP SP3
# This was run before replacing rb_file_expand_path() to funcall() in rb_expand_load_paths() of load.c.
V:\test_rails>set RUBY_USE_ATTRIBUTE=1
V:\test_rails>set RUBY_CACHED_LOAD_PATH=0
@shirosaki
shirosaki / bench_result.txt
Created December 13, 2011 15:38
Replace lstat to GetFileAttributes
ruby 2.0.0dev (2011-12-09 trunk 33995) [i386-mingw32]
Windows 7 on VirtualBox
2.4GHz Core 2 Duo
Rails 3.1.3
command: ruby script/rails r "p 1"
Average and standard deviation of 10 times trials
+----------+--------+----------+---------+
diff --git a/file.c b/file.c
index e566ce3..24b25b8 100644
--- a/file.c
+++ b/file.c
@@ -5060,7 +5060,38 @@ static int
file_load_ok(const char *path)
{
int ret = 1;
- int fd = open(path, O_RDONLY);
+ int fd;
@shirosaki
shirosaki / file_load_ok.patch
Created December 6, 2011 05:37
file_load_ok performance improvement for Windows
diff --git a/file.c b/file.c
index e566ce3..516225d 100644
--- a/file.c
+++ b/file.c
@@ -5060,7 +5060,33 @@ static int
file_load_ok(const char *path)
{
int ret = 1;
- int fd = open(path, O_RDONLY);
+ int fd;