Skip to content

Instantly share code, notes, and snippets.

View shirosaki's full-sized avatar

Hiroshi Shirosaki shirosaki

View GitHub Profile
@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|
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@
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/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)
@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/samples/mem_alloc.cpp b/samples/mem_alloc.cpp
index fb04964..4ee16ec 100644
--- a/samples/mem_alloc.cpp
+++ b/samples/mem_alloc.cpp
@@ -17,6 +17,9 @@
#include <stdexcept>
#if defined (_WIN32)
+# undef __MSVCRT_VERSION__
+# define __MSVCRT_VERSION__ 0x0700
benchmark results:
minimum results in each 5 measurements.
name ruby 2.0.0dev (2012-01-05 trunk 34217) [i386-mingw32] ruby 2.0.0dev (2012-01-05 bitmapgc 34217) [i386-mingw32] average difference
app_answer 0.344 0.234 -0.087
app_erb 18.516 2.812 -15.666
app_factorial 5.156 5.250 -0.162
app_fib 1.438 1.312 -0.109
app_mandelbrot 4.734 16.641 12.147
app_pentomino 34.250 35.781 -204.197
app_raise 1.266 1.328 0.109
diff --git a/Makefile.in b/Makefile.in
index a3040b6..e3c5d05 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -12,6 +12,7 @@ NULL = /dev/null
srcdir = @srcdir@
top_srcdir = $(srcdir)
hdrdir = $(srcdir)/include
+PLATFORM_DIR = win32
@shirosaki
shirosaki / xcpa.bat
Created January 19, 2012 00:36
Copies all files and directory trees.
@echo OFF
if "%~1" == "" goto :EOS
if "%~2" == "" goto :EOS
xcopy %1 %2 /D /S /E /H /C /Y /R /Q
goto :eof
:EOS
echo Copies all files and directory trees.
echo usage: xcpa SOURCE DESTINATION
echo.
@shirosaki
shirosaki / bench.txt
Created February 4, 2012 03:11
Long name conversion benchmark
Long name conversion of the following path.
V:\LONG_P~1\build\samples\LONG_N~1.EXE
GetLongFileName is a GetLongPathName implementation using FindFirstFile.
File exist:
GetLongPathName() time: 177.076
FindFirstFile() time: 44.9106
GetLongFileName() time: 198.462