Skip to content

Instantly share code, notes, and snippets.

@jonforums
Created November 9, 2011 17:03
Show Gist options
  • Select an option

  • Save jonforums/1352096 to your computer and use it in GitHub Desktop.

Select an option

Save jonforums/1352096 to your computer and use it in GitHub Desktop.
investigating fenix
# Assumes you have both the isolate and rake-compiler gems already installed.
C:\Users\Jon\Documents\RubyDev\fenix-git>\DevKit\devkitvars.bat
Adding the DevKit to PATH...
C:\Users\Jon\Documents\RubyDev\fenix-git>rake compile
mkdir -p tmp/i386-mingw32/fenix/1.9.3
cd tmp/i386-mingw32/fenix/1.9.3
C:/ruby193/bin/ruby.exe -I. ../../../../ext/fenix/extconf.rb --enable-debug
checking for main() in -lkernel32... yes
checking for GetFullPathNameW()... yes
checking for GetEnvironmentVariableW()... yes
creating Makefile
cd -
cd tmp/i386-mingw32/fenix/1.9.3
make
generating fenix-i386-mingw32.def
compiling ../../../../ext/fenix/fenix.c
compiling ../../../../ext/fenix/file.c
linking shared-object fenix.so
cd -
install -c tmp/i386-mingw32/fenix/1.9.3/fenix.so lib/fenix.so
C:\Users\Jon\Documents\RubyDev\fenix-git>rake bench
install -c tmp/i386-mingw32/fenix/1.9.3/fenix.so lib/fenix.so
Run options: --seed 46731
# Running tests:
................S..SSSS
Finished tests in 0.046800s, 491.4530 tests/s, 705.1282 assertions/s.
23 tests, 33 assertions, 0 failures, 0 errors, 5 skips
C:/ruby193/bin/ruby.exe -Ilib bench/file_expand_path.rb
File.expand_path: 10000 times.
Rehearsal -------------------------------------------------------------
Ruby '' 0.093000 0.422000 0.515000 ( 0.530401)
Fenix '' 0.032000 0.000000 0.032000 ( 0.031200)
Ruby '.' 0.109000 0.390000 0.499000 ( 0.499201)
Fenix '.' 0.015000 0.000000 0.015000 ( 0.015600)
Ruby 'foo', 'bar' 0.125000 0.608000 0.733000 ( 0.733201)
Fenix 'foo', 'bar' 0.031000 0.000000 0.031000 ( 0.031200)
Ruby '', 'C:/' 0.016000 0.000000 0.016000 ( 0.015600)
Fenix '', 'C:/' 0.016000 0.000000 0.016000 ( 0.015600)
Ruby 'foo', 'C:/' 0.046000 1.139000 1.185000 ( 1.185602)
Fenix 'foo', 'C:/' 0.032000 0.000000 0.032000 ( 0.031201)
Ruby '~' 0.124000 0.405000 0.529000 ( 0.546001)
Fenix '~' 0.032000 0.000000 0.032000 ( 0.031200)
Ruby '~/foo' 0.234000 0.297000 0.531000 ( 0.546001)
Fenix '~/foo' 0.031000 0.000000 0.031000 ( 0.031200)
Ruby 'foo/' 0.093000 0.390000 0.483000 ( 0.483600)
Fenix 'foo/' 0.032000 0.000000 0.032000 ( 0.031200)
Ruby '~', 'C:/Foo' 0.124000 0.437000 0.561000 ( 0.592802)
Fenix '~', 'C:/Foo' 0.032000 0.000000 0.032000 ( 0.031200)
Ruby long_path 0.093000 0.000000 0.093000 ( 0.093600)
Fenix long_path 0.078000 0.000000 0.078000 ( 0.078000)
Ruby long_path, 'rel' 0.187000 0.421000 0.608000 ( 0.608401)
Fenix long_path, 'rel' 0.094000 0.000000 0.094000 ( 0.093600)
Ruby long_path, 'C:/Foo' 0.172000 1.107000 1.279000 ( 1.279202)
Fenix long_path, 'C:/Foo' 0.093000 0.000000 0.093000 ( 0.093601)
Ruby full_long_path 0.078000 0.000000 0.078000 ( 0.078000)
Fenix full_long_path 0.078000 0.000000 0.078000 ( 0.078000)
Ruby to_path 0.063000 0.219000 0.282000 ( 0.280800)
Fenix to_path 0.031000 0.000000 0.031000 ( 0.031200)
Ruby to_path, 'rel' 0.140000 0.593000 0.733000 ( 0.733202)
Fenix to_path, 'rel' 0.047000 0.000000 0.047000 ( 0.046800)
Ruby to_path, 'C:/Foo' 0.109000 1.357000 1.466000 ( 1.482002)
Fenix to_path, 'C:/Foo' 0.031000 0.000000 0.031000 ( 0.031200)
Ruby full_to_path 0.141000 1.029000 1.170000 ( 1.170002)
Fenix full_to_path 0.031000 0.000000 0.031000 ( 0.031200)
--------------------------------------------------- total: 11.497000sec
user system total real
Ruby '' 0.125000 0.375000 0.500000 ( 0.499201)
Fenix '' 0.015000 0.000000 0.015000 ( 0.015600)
Ruby '.' 0.156000 0.343000 0.499000 ( 0.499201)
Fenix '.' 0.031000 0.000000 0.031000 ( 0.031200)
Ruby 'foo', 'bar' 0.141000 0.577000 0.718000 ( 0.733202)
Fenix 'foo', 'bar' 0.031000 0.000000 0.031000 ( 0.031200)
Ruby '', 'C:/' 0.015000 0.000000 0.015000 ( 0.015600)
Fenix '', 'C:/' 0.016000 0.000000 0.016000 ( 0.015600)
Ruby 'foo', 'C:/' 0.062000 1.201000 1.263000 ( 1.279202)
Fenix 'foo', 'C:/' 0.032000 0.000000 0.032000 ( 0.031200)
Ruby '~' 0.202000 0.390000 0.592000 ( 0.592801)
Fenix '~' 0.032000 0.000000 0.032000 ( 0.031200)
Ruby '~/foo' 0.218000 0.375000 0.593000 ( 0.592801)
Fenix '~/foo' 0.031000 0.000000 0.031000 ( 0.031200)
Ruby 'foo/' 0.109000 0.374000 0.483000 ( 0.483601)
Fenix 'foo/' 0.016000 0.000000 0.016000 ( 0.015600)
Ruby '~', 'C:/Foo' 0.156000 0.468000 0.624000 ( 0.639601)
Fenix '~', 'C:/Foo' 0.031000 0.000000 0.031000 ( 0.031200)
Ruby long_path 0.094000 0.000000 0.094000 ( 0.093601)
Fenix long_path 0.093000 0.000000 0.093000 ( 0.093600)
Ruby long_path, 'rel' 0.250000 0.359000 0.609000 ( 0.608401)
Fenix long_path, 'rel' 0.078000 0.000000 0.078000 ( 0.078000)
Ruby long_path, 'C:/Foo' 0.125000 1.186000 1.311000 ( 1.310402)
Fenix long_path, 'C:/Foo' 0.078000 0.000000 0.078000 ( 0.078000)
Ruby full_long_path 0.062000 0.015000 0.077000 ( 0.078001)
Fenix full_long_path 0.078000 0.000000 0.078000 ( 0.078000)
Ruby to_path 0.063000 0.234000 0.297000 ( 0.296400)
Fenix to_path 0.031000 0.000000 0.031000 ( 0.031200)
Ruby to_path, 'rel' 0.187000 0.562000 0.749000 ( 0.764402)
Fenix to_path, 'rel' 0.031000 0.000000 0.031000 ( 0.031200)
Ruby to_path, 'C:/Foo' 0.078000 1.373000 1.451000 ( 1.450802)
Fenix to_path, 'C:/Foo' 0.031000 0.000000 0.031000 ( 0.031200)
Ruby full_to_path 0.078000 1.107000 1.185000 ( 1.185602)
Fenix full_to_path 0.016000 0.000000 0.016000 ( 0.015600)
# Quick-n-dirty way to get started by simply copying fenix artifacts onto $LOAD_PATH.
# But this doesn't seem to work when trying to benchmarks or more serious analysis
# as fenix doesn't appear to be properly injected into MRI.
#
# TODO document how to build MRI to properly integrate fenix.
C:\Users\Jon\Documents\RubyDev\fenix-git>xcopy lib \ruby-test\193_tcs\lib\ruby\site_ruby\1.9.1\i386-msvcrt /E
lib\fenix.so
lib\fenix\replace.rb
2 File(s) copied
C:\Users\Jon\Documents\RubyDev\fenix-git>cd ..\..
# play with fenix injected into an experimental tcs-ruby
C:\Users\Jon\Documents>pik tcs-ruby
# what singleton methods exist on `Fenix::File`?
C:\Users\Jon\Documents>ruby -v -rfenix/replace -e "puts Fenix::File.singleton_methods.sort.inspect"
tcs-ruby 1.9.3p0 (2011-11-08 revision 33661) [i386-mingw32]
C:/ruby-test/193_tcs/lib/ruby/site_ruby/1.9.1/i386-msvcrt/fenix/replace.rb:3: warning: method redefined; discarding old expand_path
[:expand_path, :replace!]
# what happens when using the standard `File.expand_path` on an odd path?
C:\Users\Jon\Documents>ruby -v -e "puts File.expand_path('~..')"
tcs-ruby 1.9.3p0 (2011-11-08 revision 33661) [i386-mingw32]
-e:1:in `expand_path': can't find user .. (ArgumentError)
from -e:1:in `<main>'
# what currently happens when using `Fenix::File.expand_path` on an odd path?
C:\Users\Jon\Documents>ruby -v -rfenix/replace -e "puts File.expand_path('~..')"
tcs-ruby 1.9.3p0 (2011-11-08 revision 33661) [i386-mingw32]
C:/ruby-test/193_tcs/lib/ruby/site_ruby/1.9.1/i386-msvcrt/fenix/replace.rb:3: warning: method redefined; discarding old expand_path
C:/Users/Jon/Documents/~
# OK, how about a real path?
C:\Users\Jon\Documents>ruby -v -e "puts File.expand_path('~\.lackee')"
tcs-ruby 1.9.3p0 (2011-11-08 revision 33661) [i386-mingw32]
C:/Users/Jon/.lackee
C:\Users\Jon\Documents>ruby -v -rfenix/replace -e "puts File.expand_path('~\.lackee')"
tcs-ruby 1.9.3p0 (2011-11-08 revision 33661) [i386-mingw32]
C:/ruby-test/193_tcs/lib/ruby/site_ruby/1.9.1/i386-msvcrt/fenix/replace.rb:3: warning: method redefined; discarding old expand_path
C:/Users/Jon/.lackee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment