[#39954] Fwd: [ruby-cvs:33451] Ruby:r26235 (trunk): * trace.h: new file. wraps tracing mechanisms. — SASADA Koichi <ko1@...>

 ささだです.

16 messages 2010/01/04
[#39957] Re: Fwd: [ruby-cvs:33451] Ruby:r26235 (trunk): * trace.h: new file. wraps tracing mechanisms. — Yugui <yugui@...> 2010/01/04

2010/1/4 SASADA Koichi <ko1@atdot.net>:

[#39959] Re: Fwd: [ruby-cvs:33451] Ruby:r26235 (trunk): * trace.h: new file. wraps tracing mechanisms. — SASADA Koichi <ko1@...> 2010/01/04

 ささだです.

[#39975] [Feature #2571] 文字列のハミング距離 — Kenta Murata <redmine@...>

Feature #2571: 文字列のハミング距離

14 messages 2010/01/07

[#39978] "require 'logge'" fails on ruby 1.8.7 from http://github.com/shyouhei/ruby — MOROHASHI Kyosuke <moronatural@...>

諸橋です。

7 messages 2010/01/07

[#40004] [Bug:trunk] require_relative depends on current directory — Yusuke ENDOH <mame@...>

遠藤です。

13 messages 2010/01/09

[#40074] [Bug #2603] NetBSD 5.0以降でpthreadの処理に由来する不具合 — Takahiro Kambe <redmine@...>

Bug #2603: NetBSD 5.0以降でpthreadの処理に由来する不具合

29 messages 2010/01/14
[#40086] Re: [Bug #2603] NetBSD 5.0以降でpthreadの処理に由来する不具合 — f-miura@... (MIURA, Fumiaki) 2010/01/14

NTTレゾナントの三浦です。不完全なpatchを書いてすみません。

[#40088] Re: [Bug #2603] NetBSD 5.0以降でpthreadの処理に由来する不具合 — Takahiro Kambe <taca@...> 2010/01/14

こんばんは。

[#40091] Re: [Bug #2603] NetBSD 5.0以降でpthreadの処理に由来する不具合 — KOSAKI Motohiro <kosaki.motohiro@...> 2010/01/15

kosakiです

[#40092] Re: [Bug #2603] NetBSD 5.0以降でpthreadの処理に由来する不具合 — Takahiro Kambe <taca@...> 2010/01/15

こんにちは。

[#40077] [Bug #2604] test_dsa_sign_verify() in test/openssl/test_ec.rb failes — Takahiro Kambe <redmine@...>

Bug #2604: test_dsa_sign_verify() in test/openssl/test_ec.rb failes

11 messages 2010/01/14

[#40153] [Bug:trunk] three bugs of Matrix::Scalar — Yusuke ENDOH <mame@...>

連投すみません。

19 messages 2010/01/25
[#40184] Re: [Bug:trunk] three bugs of Matrix::Scalar — keiju@... (石塚圭樹) 2010/01/27

けいじゅ@いしつかです.

[#40189] Re: [Bug:trunk] three bugs of Matrix::Scalar — Yusuke ENDOH <mame@...> 2010/01/27

遠藤です。

[#40191] Re: [Bug:trunk] three bugs of Matrix::Scalar — keiju@... (石塚圭樹) 2010/01/27

けいじゅ@いしつかです.

[#40224] Re: [Bug:trunk] three bugs of Matrix::Scalar — Yukihiro Matsumoto <matz@...> 2010/01/28

まつもと ゆきひろです

[#40162] [Bug #2658] rubyspec: Ruby character strings interpolates the return value of Object#inspect, without ivars, if Object#to_s does not return a String instance ERROR — Yusuke Endoh <redmine@...>

Bug #2658: rubyspec: Ruby character strings interpolates the return value of Object#inspect, without ivars, if Object#to_s does not return a String instance ERROR

8 messages 2010/01/26
[#40163] Re: [Bug #2658] rubyspec: Ruby character strings interpolates the return value of Object#inspect, without ivars, if Object#to_s does not return a String instance ERROR — Tanaka Akira <akr@...> 2010/01/26

2010年1月26日20:39 Yusuke Endoh <redmine@ruby-lang.org>:

[#40168] [Bug #2662] BigDecimal#ceil, etc. should not return Integer — Yusuke Endoh <redmine@...>

Bug #2662: BigDecimal#ceil, etc. should not return Integer

10 messages 2010/01/26

[#40200] [Feature #2673] the length for an enumerator generated by Array#permutation and Array#combination — Kenta Murata <redmine@...>

Feature #2673: the length for an enumerator generated by Array#permutation and Array#combination

14 messages 2010/01/28

[#40221] [Bug:trunk] rubyspec: SimpleDelegator when frozen creates a frozen clone ERROR — Yusuke ENDOH <mame@...>

まつもとさん、または lib/delegator.rb についてわかる誰か

13 messages 2010/01/28

[#40265] MonitorMixin::ConditionVariable#wait timeout — Tanaka Akira <akr@...>

手元の Ubuntu 9.10 の環境で Ruby 1.9.2 を make test-all すると

38 messages 2010/01/30
[#40326] Re: MonitorMixin::ConditionVariable#wait timeout — Shugo Maeda <shugo@...> 2010/02/05

前田です。

[#41155] Re: MonitorMixin::ConditionVariable#wait timeout — Yusuke ENDOH <mame@...> 2010/05/05

前田さん、akr さん

[#41157] Re: MonitorMixin::ConditionVariable#wait timeout — Tanaka Akira <akr@...> 2010/05/05

2010年5月5日9:32 Yusuke ENDOH <mame@tsg.ne.jp>:

[#41158] Re: MonitorMixin::ConditionVariable#wait timeout — Yusuke ENDOH <mame@...> 2010/05/05

遠藤です。

[#41159] Re: MonitorMixin::ConditionVariable#wait timeout — Tanaka Akira <akr@...> 2010/05/05

2010年5月5日11:46 Yusuke ENDOH <mame@tsg.ne.jp>:

[#41160] Re: MonitorMixin::ConditionVariable#wait timeout — Yusuke ENDOH <mame@...> 2010/05/05

遠藤です。

[#41182] Re: MonitorMixin::ConditionVariable#wait timeout — Tanaka Akira <akr@...> 2010/05/06

2010年5月5日13:22 Yusuke ENDOH <mame@tsg.ne.jp>:

[#41183] Re: MonitorMixin::ConditionVariable#wait timeout — Yusuke ENDOH <mame@...> 2010/05/06

遠藤です。

[#41186] Re: MonitorMixin::ConditionVariable#wait timeout — Tanaka Akira <akr@...> 2010/05/06

2010年5月6日19:58 Yusuke ENDOH <mame@tsg.ne.jp>:

[#41205] Re: MonitorMixin::ConditionVariable#wait timeout — Yusuke ENDOH <mame@...> 2010/05/06

遠藤です。

[#41207] Re: MonitorMixin::ConditionVariable#wait timeout — KOSAKI Motohiro <kosaki.motohiro@...> 2010/05/06

2010年5月6日23:08 Yusuke ENDOH <mame@tsg.ne.jp>:

[#41208] Re: MonitorMixin::ConditionVariable#wait timeout — Tanaka Akira <akr@...> 2010/05/06

2010年5月6日23:15 KOSAKI Motohiro <kosaki.motohiro@gmail.com>:

[#41245] Re: MonitorMixin::ConditionVariable#wait timeout — Yusuke ENDOH <mame@...> 2010/05/10

遠藤です。

[#41252] Re: MonitorMixin::ConditionVariable#wait timeout — KOSAKI Motohiro <kosaki.motohiro@...> 2010/05/10

kosakiです

[#41255] Re: MonitorMixin::ConditionVariable#wait timeout — Yusuke ENDOH <mame@...> 2010/05/10

遠藤です。

[#41256] Re: MonitorMixin::ConditionVariable#wait timeout — Masaya TARUI <tarui@...> 2010/05/10

樽家です。

[#40269] [Feature #2695] Supported Platforms — Kazuhiro NISHIYAMA <redmine@...>

Feature #2695: Supported Platforms

17 messages 2010/01/31
[#40760] [Feature #2695] Supported Platforms — Yusuke Endoh <redmine@...> 2010/03/25

チケット #2695 が更新されました。 (by Yusuke Endoh)

[ruby-dev:39966] Re: Fwd: [ruby-cvs:33451] Ruby:r26235 (trunk): * trace.h: new file. wraps tracing mechanisms.

From: Yusuke ENDOH <mame@...>
Date: 2010-01-04 14:09:52 UTC
List: ruby-dev #39966
GyRCMXNGIyRHJDkhIxsoQgoKMjAxMBskQkcvGyhCMRskQjduGyhCNBskQkZ8GyhCMTc6MDkgWXVn
dWkgPHl1Z3VpQHl1Z3VpLmpwPjoKPj4gGyRCJCIkSCEkPVBNaCRsJFAlWSVzJUElXiE8JS83azJM
JCwkIiRrJEg0ciQ3JCQkKyRiIUobKEJwcm92ZSAbJEIkcjtJJDUkSiQkPnVCVhsoQgo+PiAbJEIk
RyROIUshJRsoQgo+Cj4gGyRCJCIhPCEiN1ckQyRGJCskaSUzJV8lQyVIJDckaCQmJEg7VyRDJEYk
JCRGSzokbCRGJF4kNyQ/ISMkZCRDJEYkXyReJDckPyEjRTpJVSQ3JF4kOSEjGyhCICh3b193LWR0
cmFjZS5sb2cpCj4gGyRCJWolUyU4JWclc0hWOWYkLD83JDckJCRbJCYkLBsoQmR0cmFjZRskQiRy
Rn4kbCQ/JGQkRCRHJDkhIxsoQgoKCmR0cmFjZSAbJEIkLCRKJCQ0RDYtGyhCIChEZWJpYW4pIBsk
QiRHJVklcyVBJV4hPCUvJHJBdiRpJDskRiRfJD8kSCQzJG0hIiQkJC8kRCQrGyhCChskQk0tMFUk
S0IuRVlOdDI9JDckRiQ9JCYkSiRIJDMkbSQsJCIkaiReJDckPyEjGyhCCgobJEJMXCRHOCskRjpG
OD1ALSROJCIkaiQ9JCYkSjQ2JDgkS0IuRVlOdDI9JDckRiQ9JCYkSiRkJEQkciVUJUMlLyUiJUMl
VxsoQjoKCiAgdm0xX25vdCAgICAgICAgOiAgMi40OCAgMy43MiAoMTUwLjAlKQogIHZtMl9zZW5k
ICAgICAgIDogIDEuMTIgIDEuNDYgKDEzMC42JSkKICB2bTFfaXZhciAgICAgICA6ICAzLjcwICA0
LjQ3ICgxMjAuNyUpCiAgdm0yX3VuaWYxICAgICAgOiAgMS4wMSAgMS4zMSAoMTI5LjYlKQogIGxv
b3Bfd2hpbGVsb29wMjogIDAuMzUgIDAuMzkgKDExMS40JSkKICBzb19hcnJheSAgICAgICA6ICA0
LjUzICA1LjAyICgxMTAuOSUpCiAgYXBwX2ZpYiAgICAgICAgOiAgMS44NyAgMi4wNyAoMTEwLjgl
KQogIHNvX2xpc3RzICAgICAgIDogIDAuOTYgIDEuMDYgKDExMC4wJSkKICBzb19iaW5hcnlfdHJl
ZXM6ICAxLjA4ICAxLjE3ICgxMDguMCUpCiAgc29fY29uY2F0ZW5hdGUgOiAgMS4wNiAgMS4xNSAo
MTA4LjAlKQogIGxvb3Bfd2hpbGVsb29wIDogIDEuNzIgIDEuODQgKDEwNi43JSkKICBzb19uc2ll
dmUgICAgICA6ICA4LjUxICA5LjA0ICgxMDYuMiUpCiAgaW9fZmlsZV9jcmVhdGUgOiAgMC43MSAg
MC43NCAoMTAzLjklKQogIGFwcF9wZW50b21pbm8gIDogNDkuMzQgNTEuMTcgKDEwMy43JSkKICBz
b19leGNlcHRpb24gICA6ICAyLjc1ICAyLjgzICgxMDMuMCUpCiAgYXBwX2ZhY3RvcmlhbCAgOiAg
MC40OCAgMC40OSAoMTAyLjMlKQoKcjI2MjM0IBskQiRIGyhCIHIyNjIzOCAbJEIkR0hmM1MkNyRG
JCQkXiQ5ISMbKEIKGyRCM0YlWSVzJUElXiE8JS8kTxsoQiA1IBskQjJzQXYkaSQ7JEYhIiQ9JE5D
ZiROOkdCLiRIOkdDWSROGyhCIDIgGyRCJEQkcj18JCQkPyVHITwlPyROGyhCChskQko/NlEkR0hm
M1MkNyRGJCQkXiQ5ISMbKEIKChskQjVVJEtBYSQvJEokQyRGJCQkayRIJDMkbSRiJCIkayROJEch
IiUzJXMlUSUkJWkkTjpHRSwyPSROJFYkbCRKJE4kKyRiJDckbBsoQgobJEIkXiQ7JHMkLCEiGyhC
dm0qIBskQjdPJE4lWSVzJUElXiE8JS8kTk50Mj0kQyRXJGokT0w1O2skNyQ/JC8kSiQkJEckOSRN
ISMbKEIKCgobJEIkPyRAISIkJiRBJE40RDYtJCwkSiRzJCtKUSRKJEAkMSQrJGIkNyRsJEokJCRO
JEchIkMvJCtESTtuJDckRiQvJEAkNSQkISMbKEIKCgokIG1ha2UgYmVuY2htYXJrIENPTVBBUkVf
UlVCWT0nYmVmb3JlOjogLi9ydWJ5LjI2MjM0JyBPUFRTPSctciA1JwpSVUJZTElCPS9ob21lL21h
bWUvd29yay9ydWJ5L2xpYjovaG9tZS9tYW1lL3dvcmsvcnVieS8uZXh0L2k2ODYtbGludXgKPiBi
ZW5jaG1hcmsubG9nICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWw6IDM1MCB0cmlhbChz
KSAoNQp0cmlhbChzKSBmb3IgNzAgYmVuY2htYXJrKHMpKQouLi4uLi4uLi4uLi4uLi4uLi4uLi4u
Li4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
Li4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
Li4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
Li4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
Li4uLi4uLi4uLi4uLi4uLi4uLi5wcmVwYXJpbmcKLi9iZW5jaG1hcmsvZmFzdGEub3V0cHV0LjEw
MDAwMAouLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
Li4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
Li4uLi4uLi4uLi4uLi4uLi4uLi4ucHJlcGFyaW5nCi4vYmVuY2htYXJrL2Zhc3RhLm91dHB1dC4y
NTAwMDAwCi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
Li4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
Li4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
Li4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
Li4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4u
Li4uLi4uLi4uLi4uLi4uLi4uLi4uLi9ob21lL21hbWUvd29yay9ydWJ5L2xpYi9wcC5yYjoxMTA6
aW4KYGd1YXJkX2luc3BlY3Rfa2V5JzogdW5kZWZpbmVkIG1ldGhvZCBgdW50cnVzdCcgZm9yIHt9
Okhhc2gKKE5vTWV0aG9kRXJyb3IpCiAgICAgICAgZnJvbSAvaG9tZS9tYW1lL3dvcmsvcnVieS9s
aWIvcHAucmI6Nzc6aW4gYHBwJwogICAgICAgIGZyb20gLi9iZW5jaG1hcmsvZHJpdmVyLnJiOjEw
MDppbiBgc2hvd19yZXN1bHRzJwogICAgICAgIGZyb20gLi9iZW5jaG1hcmsvZHJpdmVyLnJiOjI4
OmluIGBiZW5jaG1hcmsnCiAgICAgICAgZnJvbSAuL2JlbmNobWFyay9kcml2ZXIucmI6MjQ5Cm1h
a2U6ICoqKiBbYmVuY2htYXJrXSAbJEIlKCVpITwbKEIgMQoKGyRCIiwkQSRKJF8kSyEiGyhCYmVu
Y2htYXJrIBskQiU5JS8laiVXJUgkLCQzJHMkSkl3JEtNbiRBJD8kTiRHGyhCIHJhdyBkYXRhIBsk
QiQsRkAkaSRsGyhCChskQiReJDskcyRHJDckPyEjGyhCCgotLSAKWXVzdWtlIEVORE9IIDxtYW1l
QHRzZy5uZS5qcD4K

Attachments (1)

benchmark.log (88.2 KB, text/html)
ruby ./benchmark/driver.rb -v \
	            --executables="before:: ./ruby.26234; ./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb  ./tool/runruby.rb --extout=.ext  --" \
	            --pattern='bm_' --directory=./benchmark -r 5
Mon Jan 04 19:47:43 +0900 2010
target 0: before
target 1: ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]

-----------------------------------------------------------
app_answer

def ack(m, n)
  if m == 0 then
    n + 1
  elsif n == 0 then
    ack(m - 1, 1)
  else
    ack(m - 1, ack(m, n - 1))
  end
end

def the_answer_to_life_the_universe_and_everything
  (ack(3,7).to_s.split(//).inject(0){|s,x| s+x.to_i}.to_s + "2" ).to_i
end

answer = the_answer_to_life_the_universe_and_everything

before	0.286792993545532
before	0.282000780105591
before	0.286011934280396
before	0.27987003326416
before	0.285646915435791
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.253024101257324
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.252955913543701
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.254228115081787
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.252812147140503
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.254550933837891

-----------------------------------------------------------
app_erb

#
# Create many HTML strings with ERB.
#

require 'erb'

data = DATA.read
max = 5_000
title = "hello world!"
content = "hello world!\n" * 10

max.times{
  ERB.new(data).result(binding)
}

__END__

<html>
  <head> <%= title %> </head>
  <body>
    <h1> <%= title %> </h1>
    <p>
      <%= content %>
    </p>
  </body>
</html>

before	1.84134101867676
before	1.83239507675171
before	1.84679198265076
before	1.82841920852661
before	1.8467230796814
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.85409617424011
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.82655191421509
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.85079288482666
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.84551191329956
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.82545876502991

-----------------------------------------------------------
app_factorial

def fact(n)
  if(n > 1)
    n * fact(n-1)
  else
    1
  end
end

8.times{
  fact(5000)
}

before	0.788949966430664
before	0.787946939468384
before	0.796578884124756
before	0.870213031768799
before	0.797021865844727
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.812771081924438
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.8124840259552
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.813491106033325
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.810642004013062
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.813281059265137

-----------------------------------------------------------
app_fib

def fib n
  if n < 3
    1
  else
    fib(n-1) + fib(n-2)
  end
end

fib(34)


before	3.1692271232605
before	3.04353189468384
before	3.08895897865295
before	3.0690381526947
before	3.255774974823
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.41784691810608
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.52016592025757
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.41149401664734
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.50184607505798
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.26958990097046

-----------------------------------------------------------
app_mandelbrot

require 'complex'

def mandelbrot? z
  i = 0
  while i<100
    i+=1
    z = z * z
    return false if z.abs > 2
  end
  true
end

ary = []

(0..100).each{|dx|
  (0..100).each{|dy|
    x = dx / 50.0
    y = dy / 50.0
    c = Complex(x, y)
    ary << c if mandelbrot?(c)
  }
}


before	0.801680088043213
before	0.787177085876465
before	0.797647953033447
before	0.82262110710144
before	0.816313982009888
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.804239988327026
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.807985067367554
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.806362867355347
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.802676916122437
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.804014205932617

-----------------------------------------------------------
app_pentomino

#!/usr/local/bin/ruby
# This program is contributed by Shin Nishiyama


# modified by K.Sasada

NP = 5
ROW = 8 + NP
COL = 8

$p = []
$b = []
$no = 0

def piece(n, a, nb)
  nb.each{|x|
    a[n] = x
    if n == NP-1
      $p << [a.sort]
    else
      nbc=nb.dup
      [-ROW, -1, 1, ROW].each{|d|
        if x+d > 0 and not a.include?(x+d) and not nbc.include?(x+d)
          nbc << x+d
        end
      }
      nbc.delete x
      piece(n+1,a[0..n],nbc)
    end
  }
end

def kikaku(a)
  a.collect {|x| x - a[0]}
end
def ud(a)
  kikaku(a.collect {|x| ((x+NP)%ROW)-ROW*((x+NP)/ROW) }.sort)
end
def rl(a)
  kikaku(a.collect {|x| ROW*((x+NP)/ROW)+ROW-((x+NP)%ROW)}.sort)
end
def xy(a)
  kikaku(a.collect {|x| ROW*((x+NP)%ROW) + (x+NP)/ROW }.sort)
end

def mkpieces
  piece(0,[],[0])
  $p.each do |a|
    a0 = a[0]
    a[1] = ud(a0)
    a[2] = rl(a0)
    a[3] = ud(rl(a0))
    a[4] = xy(a0)
    a[5] = ud(xy(a0))
    a[6] = rl(xy(a0))
    a[7] = ud(rl(xy(a0)))
    a.sort!
    a.uniq!
  end
  $p.uniq!.sort! {|x,y| x[0] <=> y[0] }
end

def mkboard
  (0...ROW*COL).each{|i|
    if i % ROW >= ROW-NP
      $b[i] = -2
    else
      $b[i] = -1
    end
    $b[3*ROW+3]=$b[3*ROW+4]=$b[4*ROW+3]=$b[4*ROW+4]=-2
  }
end

def pboard
  return # skip print
  print "No. #$no\n"
  (0...COL).each{|i|
    print "|"
    (0...ROW-NP).each{|j|
      x = $b[i*ROW+j]
      if x < 0
        print "..|"
      else
        printf "%2d|",x+1
      end
    }
    print "\n"
  }
  print "\n"
end

$pnum=[]
def setpiece(a,pos)
  if a.length == $p.length then
    $no += 1
    pboard
    return
  end
  while $b[pos] != -1
    pos += 1
  end
  ($pnum - a).each do |i|
    $p[i].each do |x|
      f = 0
      x.each{|s|
        if $b[pos+s] != -1
          f=1
          break
        end
      }
      if f == 0 then
        x.each{|s|
          $b[pos+s] = i
        }
        a << i
        setpiece(a.dup, pos)
        a.pop
        x.each{|s|
          $b[pos+s] = -1
        }
      end
    end
  end
end

mkpieces
mkboard
$p[4] = [$p[4][0]]
$pnum = (0...$p.length).to_a
setpiece([],0)


__END__

# original

NP = 5
ROW = 8 + NP
COL = 8

$p = []
$b = []
$no = 0

def piece(n,a,nb)
  for x in nb
    a[n] = x
    if n == NP-1
      $p << [a.sort]
    else
      nbc=nb.dup
      for d in [-ROW, -1, 1, ROW]
        if x+d > 0 and not a.include?(x+d) and not nbc.include?(x+d)
          nbc << x+d
        end
      end
      nbc.delete x
      piece(n+1,a[0..n],nbc)
    end
  end
end

def kikaku(a)
  a.collect {|x| x - a[0]}
end
def ud(a)
  kikaku(a.collect {|x| ((x+NP)%ROW)-ROW*((x+NP)/ROW) }.sort)
end
def rl(a)
  kikaku(a.collect {|x| ROW*((x+NP)/ROW)+ROW-((x+NP)%ROW)}.sort)
end
def xy(a)
  kikaku(a.collect {|x| ROW*((x+NP)%ROW) + (x+NP)/ROW }.sort)
end

def mkpieces
  piece(0,[],[0])
  $p.each do |a|
    a0 = a[0]
    a[1] = ud(a0)
    a[2] = rl(a0)
    a[3] = ud(rl(a0))
    a[4] = xy(a0)
    a[5] = ud(xy(a0))
    a[6] = rl(xy(a0))
    a[7] = ud(rl(xy(a0)))
    a.sort!
    a.uniq!
  end
  $p.uniq!.sort! {|x,y| x[0] <=> y[0] }
end

def mkboard
  for i in 0...ROW*COL
    if i % ROW >= ROW-NP
      $b[i] = -2
    else
      $b[i] = -1
    end
    $b[3*ROW+3]=$b[3*ROW+4]=$b[4*ROW+3]=$b[4*ROW+4]=-2
  end
end

def pboard
  print "No. #$no\n"
  for i in 0...COL
    print "|"
    for j in 0...ROW-NP
      x = $b[i*ROW+j]
      if x < 0
        print "..|"
      else
        printf "%2d|",x+1
      end
    end
    print "\n"
  end
  print "\n"
end

$pnum=[]
def setpiece(a,pos)
  if a.length == $p.length then
    $no += 1
    pboard
    return
  end
  while $b[pos] != -1
    pos += 1
  end
  ($pnum - a).each do |i|
    $p[i].each do |x|
      f = 0
      for s in x do
        if $b[pos+s] != -1
          f=1
          break
        end
      end
      if f == 0 then
        for s in x do
          $b[pos+s] = i
        end
        a << i
        setpiece(a.dup, pos)
        a.pop
        for s in x do
          $b[pos+s] = -1
        end
      end
    end
  end
end

mkpieces
mkboard
$p[4] = [$p[4][0]]
$pnum = (0...$p.length).to_a
setpiece([],0)

before	82.4051730632782
before	81.8011980056763
before	82.1274840831757
before	82.1822559833527
before	82.9355120658875
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	84.9107260704041
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	86.0348889827728
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	85.15940284729
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	85.0050840377808
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	85.7057631015778

-----------------------------------------------------------
app_raise

i=0
while i<300000
  i+=1
  begin
    raise
  rescue
  end
end

before	2.06929206848145
before	2.02867603302002
before	2.02058219909668
before	2.07236289978027
before	2.03075098991394
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.10460305213928
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.07866191864014
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.08692908287048
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.12837791442871
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.12551498413086

-----------------------------------------------------------
app_strconcat

i=0
while i<500000
  "#{1+1} #{1+1} #{1+1}"
  i+=1
end

before	1.54019713401794
before	1.52541017532349
before	1.56333899497986
before	1.56849193572998
before	1.5396580696106
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.57516980171204
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.56870698928833
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.56517314910889
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.55529689788818
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.58040499687195

-----------------------------------------------------------
app_tak


def tak x, y, z
  unless y < x
    z
  else
    tak( tak(x-1, y, z),
         tak(y-1, z, x),
         tak(z-1, x, y))
  end
end

tak(18, 9, 0)


before	5.16915011405945
before	5.03239178657532
before	5.0472559928894
before	5.00584292411804
before	5.19915199279785
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.40196394920349
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.50192713737488
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.45308804512024
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.41482210159302
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.48149800300598

-----------------------------------------------------------
app_tarai

def tarai( x, y, z )
  if x <= y
  then y
  else tarai(tarai(x-1, y, z),
             tarai(y-1, z, x),
             tarai(z-1, x, y))
  end
end

tarai(12, 6, 0)

before	3.37822198867798
before	3.33238101005554
before	3.44754505157471
before	3.37771701812744
before	3.37433099746704
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.23274397850037
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.18672299385071
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.25112891197205
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.25346899032593
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.24488592147827

-----------------------------------------------------------
app_uri

require 'uri'

100_000.times{
  uri = URI.parse('http://www.ruby-lang.org')
  uri.scheme
  uri.host
  uri.port
}

before	3.75685214996338
before	3.73731708526611
before	3.72245383262634
before	3.71082401275635
before	3.72123599052429
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.75104403495789
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.88088417053223
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.77906918525696
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.76118302345276
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.76186895370483

-----------------------------------------------------------
io_file_create

#
# Create files
#

max = 50_000
file = './tmpfile_of_bm_io_file_create'

max.times{
  f = open(file, 'w')
  f.close#(true)
}
File.unlink(file)


before	1.18349194526672
before	1.47565412521362
before	1.17227602005005
before	1.18126106262207
before	1.17488598823547
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.21884107589722
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.22250390052795
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.2248101234436
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.23556399345398
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.23201990127563

-----------------------------------------------------------
io_file_read

#
# Seek and Read file.
#

require 'tempfile'

max = 20_000
str = "Hello world!  " * 1000
f = Tempfile.new('yarv-benchmark')
f.write str

max.times{
  f.seek 0
  f.read
}

before	0.92747688293457
before	0.927958011627197
before	0.931061983108521
before	0.925689935684204
before	0.949116945266724
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.0092499256134
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.946033000946045
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.945067167282104
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.955148935317993
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.952633142471313

-----------------------------------------------------------
io_file_write

#
# Seek and Write file.
#

require 'tempfile'

max = 20_000
str = "Hello world!  " * 1000
f = Tempfile.new('yarv-benchmark')

max.times{
  f.seek 0
  f.write str
}

before	0.371242046356201
before	0.367892980575562
before	0.368409156799316
before	0.369699001312256
before	0.364259004592896
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.388603925704956
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.388659000396729
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.391710996627808
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.389502048492432
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.393227100372314

-----------------------------------------------------------
loop_for

for i in 1..30_000_000
  #
end

before	6.77330112457275
before	6.76733922958374
before	6.9457528591156
before	6.95300388336182
before	6.82293701171875
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	7.5270631313324
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	7.24850988388062
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.70435905456543
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	7.1608669757843
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.58003997802734

-----------------------------------------------------------
loop_generator

max = 600000

if defined? Fiber
  gen = (1..max).each
  loop do
    gen.next
  end
else
  require 'generator'
  gen = Generator.new((0..max))
  while gen.next?
    gen.next
  end
end

before	2.47027707099915
before	2.47239899635315
before	2.48207187652588
before	2.45607995986938
before	2.63115191459656
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.49859404563904
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.47396111488342
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.50387477874756
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.47075510025024
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.53988599777222

-----------------------------------------------------------
loop_times

30_000_000.times{|e|}

before	6.02881789207458
before	6.05763101577759
before	6.10677909851074
before	5.96658301353455
before	5.94578695297241
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.00088405609131
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.78694915771484
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.16235995292664
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.91692590713501
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.91468405723572

-----------------------------------------------------------
loop_whileloop

i=0
while i<30_000_000 # benchmark loop 1
  i+=1
end

before	2.85792207717896
before	2.85251402854919
before	2.89838910102844
before	2.88608312606812
before	2.76239609718323
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.20222496986389
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.93890309333801
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.96414089202881
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.1907799243927
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.02121591567993

-----------------------------------------------------------
loop_whileloop2

i=0
while i< 6_000_000 # benchmark loop 2
  i+=1
end

before	0.587778091430664
before	0.594327926635742
before	0.583711862564087
before	0.58557391166687
before	0.582841157913208
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.665136098861694
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.623836994171143
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.628025054931641
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.663863182067871
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.671785116195679

-----------------------------------------------------------
so_ackermann

#!/usr/bin/ruby
# -*- mode: ruby -*-
# $Id: ackermann-ruby.code,v 1.4 2004/11/13 07:40:41 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/

def ack(m, n)
    if m == 0 then
        n + 1
    elsif n == 0 then
        ack(m - 1, 1)
    else
        ack(m - 1, ack(m, n - 1))
    end
end

NUM = 9
ack(3, NUM)



before	4.31442499160767
before	4.31358003616333
before	4.31301403045654
before	4.16195011138916
before	4.30498099327087
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.53378582000732
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.61204981803894
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.59026503562927
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.54347085952759
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.61617493629456

-----------------------------------------------------------
so_array

#!/usr/bin/ruby
# -*- mode: ruby -*-
# $Id: ary-ruby.code,v 1.4 2004/11/13 07:41:27 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/
# with help from Paul Brannan and Mark Hubbart

n = 9000 # Integer(ARGV.shift || 1)

x = Array.new(n)
y = Array.new(n, 0)

n.times{|bi|
  x[bi] = bi + 1
}

(0 .. 999).each do |e|
  (n-1).step(0,-1) do |bi|
    y[bi] += x.at(bi)
  end
end
# puts "#{y.first} #{y.last}"



before	7.63312005996704
before	7.46926498413086
before	7.60904908180237
before	7.54677700996399
before	7.47228503227234
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	8.38237690925598
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	8.32261204719543
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	8.45480489730835
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	8.3300769329071
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	8.38738512992859

-----------------------------------------------------------
so_binary_trees

# The Computer Language Shootout Benchmarks
# http://shootout.alioth.debian.org
#
# contributed by Jesse Millikan

# disable output
def STDOUT.write_ *args
end

def item_check(tree)
 if tree[0] == nil
  tree[1]
 else
  tree[1] + item_check(tree[0]) - item_check(tree[2])
 end
end

def bottom_up_tree(item, depth)
 if depth > 0
  item_item = 2 * item
  depth -= 1
  [bottom_up_tree(item_item - 1, depth), item, bottom_up_tree(item_item, depth)]
 else
  [nil, item, nil]
 end
end

max_depth = 12 # 16 # ARGV[0].to_i
min_depth = 4

max_depth = min_depth + 2 if min_depth + 2 > max_depth

stretch_depth = max_depth + 1
stretch_tree = bottom_up_tree(0, stretch_depth)

puts "stretch tree of depth #{stretch_depth}\t check: #{item_check(stretch_tree)}"
stretch_tree = nil

long_lived_tree = bottom_up_tree(0, max_depth)

min_depth.step(max_depth + 1, 2) do |depth|
 iterations = 2**(max_depth - depth + min_depth)

 check = 0

 for i in 1..iterations
  temp_tree = bottom_up_tree(i, depth)
  check += item_check(temp_tree)

  temp_tree = bottom_up_tree(-i, depth)
  check += item_check(temp_tree)
 end

 puts "#{iterations * 2}\t trees of depth #{depth}\t check: #{check}"
end

puts "long lived tree of depth #{max_depth}\t check: #{item_check(long_lived_tree)}"

before	1.83944201469421
before	1.80178499221802
before	1.80621886253357
before	1.78678703308105
before	1.77689909934998
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.98464798927307
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.93534994125366
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.91602301597595
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.95885705947876
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.93168306350708

-----------------------------------------------------------
so_concatenate

#!/usr/bin/ruby
# -*- mode: ruby -*-
# $Id: strcat-ruby.code,v 1.4 2004/11/13 07:43:28 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/
# based on code from Aristarkh A Zagorodnikov and Dat Nguyen

STUFF = "hello\n"
i=0
while i<10
  i+=1
  hello = ''
  400000.times do |e|
    hello << STUFF
  end
end
# puts hello.length



before	1.7808039188385
before	1.754967212677
before	1.80587005615234
before	1.76548004150391
before	1.76728487014771
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.94740915298462
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.91259407997131
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.90783095359802
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.88598203659058
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.92011189460754

-----------------------------------------------------------
so_count_words

#!/usr/bin/ruby
# -*- mode: ruby -*-
# $Id: wc-ruby.code,v 1.4 2004/11/13 07:43:32 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/
# with help from Paul Brannan

input = open(File.join(File.dirname($0), 'wc.input'), 'rb')

nl = nw = nc = 0
while true
  tmp = input.read(4096) or break
  data = tmp << (input.gets || "")
  nc += data.length
  nl += data.count("\n")
  ((data.strip! || data).tr!("\n", " ") || data).squeeze!
  nw += data.count(" ") + 1
end
# STDERR.puts "#{nl} #{nw} #{nc}"


before	0.760000944137573
before	0.756428956985474
before	0.753935098648071
before	0.75316596031189
before	0.752789974212646
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.761961936950684
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.757724046707153
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.758681058883667
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.756570100784302
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.759639978408813

-----------------------------------------------------------
so_exception

#!/usr/bin/ruby
# -*- mode: ruby -*-
# $Id: except-ruby.code,v 1.4 2004/11/13 07:41:33 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/

$HI = 0
$LO = 0
NUM = 250000 # Integer(ARGV[0] || 1)


class Lo_Exception < Exception
  def initialize(num)
    @value = num
  end
end

class Hi_Exception < Exception
  def initialize(num)
    @value = num
  end
end

def some_function(num)
  begin
    hi_function(num)
  rescue
    print "We shouldn't get here, exception is: #{$!.type}\n"
  end
end

def hi_function(num)
  begin
    lo_function(num)
  rescue Hi_Exception
    $HI = $HI + 1
  end
end

def lo_function(num)
  begin
    blowup(num)
  rescue Lo_Exception
    $LO = $LO + 1
  end
end

def blowup(num)
  if num % 2 == 0
    raise Lo_Exception.new(num)
  else
    raise Hi_Exception.new(num)
  end
end


i = 1
max = NUM+1
while i < max
  i+=1
  some_function(i+1)
end

before	4.59208488464355
before	4.53487014770508
before	4.5505678653717
before	4.61681604385376
before	4.58906292915344
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.73220682144165
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.65446400642395
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.71078300476074
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.71320700645447
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.72570395469666

-----------------------------------------------------------
so_fannkuch

# The Computer Language Shootout
# http://shootout.alioth.debian.org/
# Contributed by Sokolov Yura
# Modified by Ryan Williams

def fannkuch(n)
   maxFlips, m, r, check = 0, n-1, n, 0
   count = (1..n).to_a
   perm = (1..n).to_a

   while true
      if check < 30
         puts "#{perm}"
         check += 1
      end

      while r != 1
         count[r-1] = r
         r -= 1
      end

      if perm[0] != 1 and perm[m] != n
         perml = perm.clone #.dup
         flips = 0
         while (k = perml.first ) != 1
            perml = perml.slice!(0, k).reverse + perml
            flips += 1
         end
         maxFlips = flips if flips > maxFlips
      end
      while true
         if r==n then return maxFlips end
         perm.insert r,perm.shift
         break if (count[r] -= 1) > 0
         r += 1
      end
   end
end

def puts *args
end

N = 10 # (ARGV[0] || 1).to_i
puts "Pfannkuchen(#{N}) = #{fannkuch(N)}"


before	77.0769870281219
before	76.9635851383209
before	77.1030750274658
before	77.0806088447571
before	77.5384809970856
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	76.1433370113373
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	76.21608710289
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	76.4133801460266
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	76.0821650028229
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	76.3303740024567

-----------------------------------------------------------
so_fasta

# The Computer Language Shootout
# http://shootout.alioth.debian.org/
# Contributed by Sokolov Yura

$last = 42.0
def gen_random (max,im=139968,ia=3877,ic=29573)
    (max * ($last = ($last * ia + ic) % im)) / im
end

alu =
   "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG"+
   "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA"+
   "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT"+
   "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA"+
   "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG"+
   "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC"+
   "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"

iub = [
    ["a", 0.27],
    ["c", 0.12],
    ["g", 0.12],
    ["t", 0.27],

    ["B", 0.02],
    ["D", 0.02],
    ["H", 0.02],
    ["K", 0.02],
    ["M", 0.02],
    ["N", 0.02],
    ["R", 0.02],
    ["S", 0.02],
    ["V", 0.02],
    ["W", 0.02],
    ["Y", 0.02],
]
homosapiens = [
    ["a", 0.3029549426680],
    ["c", 0.1979883004921],
    ["g", 0.1975473066391],
    ["t", 0.3015094502008],
]

def make_repeat_fasta(id, desc, src, n)
    puts ">#{id} #{desc}"
    v = nil
    width = 60
    l = src.length
    s = src * ((n / l) + 1)
    s.slice!(n, l)
    puts(s.scan(/.{1,#{width}}/).join("\n"))
end

def make_random_fasta(id, desc, table, n)
    puts ">#{id} #{desc}"
    rand, v = nil,nil
    width = 60
    chunk = 1 * width
    prob = 0.0
    table.each{|v| v[1]= (prob += v[1])}
    for i in 1..(n/width)
        puts((1..width).collect{
            rand = gen_random(1.0)
            table.find{|v| v[1]>rand}[0]
        }.join)
    end
    if n%width != 0
        puts((1..(n%width)).collect{
            rand = gen_random(1.0)
            table.find{|v| v[1]>rand}[0]
        }.join)
    end
end


n = (ARGV[0] or 250_000).to_i

make_repeat_fasta('ONE', 'Homo sapiens alu', alu, n*2)
make_random_fasta('TWO', 'IUB ambiguity codes', iub, n*3)
make_random_fasta('THREE', 'Homo sapiens frequency', homosapiens, n*5)


before	10.2439229488373
before	10.2834670543671
before	10.1762020587921
before	10.1959018707275
before	10.2472558021545
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	10.1971900463104
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	10.2768731117249
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	10.1174929141998
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	10.1234829425812
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	10.2634642124176

-----------------------------------------------------------
so_k_nucleotide

# The Computer Language Shootout
# http://shootout.alioth.debian.org
#
# contributed by jose fco. gonzalez
# modified by Sokolov Yura

seq = String.new

def frecuency( seq,length )
    n, table = seq.length - length + 1, Hash.new(0)
    f, i = nil, nil
    (0 ... length).each do |f|
        (f ... n).step(length) do |i|
            table[seq[i,length]] += 1
        end
    end
    [n,table]

end

def sort_by_freq( seq,length )
    n,table = frecuency( seq,length )
    a, b, v = nil, nil, nil
    table.sort{|a,b| b[1] <=> a[1]}.each do |v|
        puts "%s %.3f" % [v[0].upcase,((v[1]*100).to_f/n)]
    end
    puts
end

def find_seq( seq,s )
    n,table = frecuency( seq,s.length )
    puts "#{table[s].to_s}\t#{s.upcase}"
end

input = open(File.join(File.dirname($0), 'fasta.output.100000'), 'rb')

line = input.gets while line !~ /^>THREE/
line = input.gets

while (line !~ /^>/) & line do
    seq << line.chomp
    line = input.gets
end

[1,2].each {|i| sort_by_freq( seq,i ) }

%w(ggt ggta ggtatt ggtattttaatt ggtattttaatttatagt).each{|s| find_seq( seq,s) }


before	6.95488905906677
before	6.91057395935059
before	6.91449594497681
before	6.9749870300293
before	6.82723689079285
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.73967313766479
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.77025389671326
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.6418468952179
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.78495192527771
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.63620591163635

-----------------------------------------------------------
so_lists

#from http://www.bagley.org/~doug/shootout/bench/lists/lists.ruby

NUM = 100
SIZE = 10000

def test_lists()
  # create a list of integers (Li1) from 1 to SIZE
  li1 = (1..SIZE).to_a
  # copy the list to li2 (not by individual items)
  li2 = li1.dup
  # remove each individual item from left side of li2 and
  # append to right side of li3 (preserving order)
  li3 = Array.new
  while (not li2.empty?)
    li3.push(li2.shift)
  end
  # li2 must now be empty
  # remove each individual item from right side of li3 and
  # append to right side of li2 (reversing list)
  while (not li3.empty?)
    li2.push(li3.pop)
  end
  # li3 must now be empty
  # reverse li1 in place
  li1.reverse!
  # check that first item is now SIZE
  if li1[0] != SIZE then
    p "not SIZE"
    0
  else
    # compare li1 and li2 for equality
    if li1 != li2 then
      return(0)
    else
      # return the length of the list
      li1.length
    end
  end
end

i = 0
while i<NUM
  i+=1
  result = test_lists()
end

result

before	1.6212329864502
before	1.58210301399231
before	1.60351300239563
before	1.62014389038086
before	1.57751893997192
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.75767302513123
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.77093410491943
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.75846004486084
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.72855806350708
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.79337692260742

-----------------------------------------------------------
so_mandelbrot

#  The Computer Language Benchmarks Game
#  http://shootout.alioth.debian.org/
#
#  contributed by Karl von Laudermann
#  modified by Jeremy Echols

size = 600 # ARGV[0].to_i

puts "P4\n#{size} #{size}"

ITER = 49                           # Iterations - 1 for easy for..in looping
LIMIT_SQUARED = 4.0                 # Presquared limit

byte_acc = 0
bit_num = 0

count_size = size - 1               # Precomputed size for easy for..in looping

# For..in loops are faster than .upto, .downto, .times, etc.
for y in 0..count_size
  for x in 0..count_size
    zr = 0.0
    zi = 0.0
    cr = (2.0*x/size)-1.5
    ci = (2.0*y/size)-1.0
    escape = false

    # To make use of the for..in code, we use a dummy variable,
    # like one would in C
    for dummy in 0..ITER
      tr = zr*zr - zi*zi + cr
      ti = 2*zr*zi + ci
      zr, zi = tr, ti

      if (zr*zr+zi*zi) > LIMIT_SQUARED
        escape = true
        break
      end
    end

    byte_acc = (byte_acc << 1) | (escape ? 0b0 : 0b1)
    bit_num += 1

    # Code is very similar for these cases, but using separate blocks
    # ensures we skip the shifting when it's unnecessary, which is most cases.
    if (bit_num == 8)
      print byte_acc.chr
      byte_acc = 0
      bit_num = 0
    elsif (x == count_size)
      byte_acc <<= (8 - bit_num)
      print byte_acc.chr
      byte_acc = 0
      bit_num = 0
    end
  end
end

before	22.65056681633
before	23.026034116745
before	22.7141489982605
before	22.8460719585419
before	23.0098421573639
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	23.4477310180664
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	22.9736950397491
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	23.1878080368042
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	26.8487520217896
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	22.8093421459198

-----------------------------------------------------------
so_matrix

#!/usr/bin/ruby
# -*- mode: ruby -*-
# $Id: matrix-ruby.code,v 1.4 2004/11/13 07:42:14 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/

n = 60 #Integer(ARGV.shift || 1)

size = 30

def mkmatrix(rows, cols)
    count = 1
    mx = Array.new(rows)
    (0 .. (rows - 1)).each do |bi|
        row = Array.new(cols, 0)
        (0 .. (cols - 1)).each do |j|
            row[j] = count
            count += 1
        end
        mx[bi] = row
    end
    mx
end

def mmult(rows, cols, m1, m2)
    m3 = Array.new(rows)
    (0 .. (rows - 1)).each do |bi|
        row = Array.new(cols, 0)
        (0 .. (cols - 1)).each do |j|
            val = 0
            (0 .. (cols - 1)).each do |k|
                val += m1.at(bi).at(k) * m2.at(k).at(j)
            end
            row[j] = val
        end
        m3[bi] = row
    end
    m3
end

m1 = mkmatrix(size, size)
m2 = mkmatrix(size, size)
mm = Array.new
n.times do
    mm = mmult(size, size, m1, m2)
end
# puts "#{mm[0][0]} #{mm[2][3]} #{mm[3][2]} #{mm[4][4]}"



before	1.84389209747314
before	1.82999491691589
before	1.91079497337341
before	1.97416591644287
before	1.90986514091492
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.16414785385132
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.04840183258057
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.96360898017883
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.93131995201111
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.95685887336731

-----------------------------------------------------------
so_meteor_contest

#!/usr/bin/env ruby
#
# The Computer Language Shootout
#   http://shootout.alioth.debian.org
#   contributed by Kevin Barnes (Ruby novice)

# PROGRAM:  the main body is at the bottom.
#   1) read about the problem here: http://www-128.ibm.com/developerworks/java/library/j-javaopt/
#   2) see how I represent a board as a bitmask by reading the blank_board comments
#   3) read as your mental paths take you

def print *args
end

# class to represent all information about a particular rotation of a particular piece
class Rotation
  # an array (by location) containing a bit mask for how the piece maps at the given location.
  # if the rotation is invalid at that location the mask will contain false
  attr_reader :start_masks

  # maps a direction to a relative location.  these differ depending on whether it is an even or
  # odd row being mapped from
  @@rotation_even_adder = { :west => -1, :east => 1, :nw => -7, :ne => -6, :sw => 5, :se => 6 }
  @@rotation_odd_adder = { :west => -1, :east => 1, :nw => -6, :ne => -5, :sw => 6, :se => 7 }

  def initialize( directions )
    @even_offsets, @odd_offsets = normalize_offsets( get_values( directions ))

    @even_mask = mask_for_offsets( @even_offsets)
    @odd_mask = mask_for_offsets( @odd_offsets)

    @start_masks = Array.new(60)

    # create the rotational masks by placing the base mask at the location and seeing if
    # 1) it overlaps the boundries and 2) it produces a prunable board.  if either of these
    # is true the piece cannot be placed
    0.upto(59) do | offset |
      mask = is_even(offset) ? (@even_mask << offset) : (@odd_mask << offset)
      if (blank_board & mask == 0 && !prunable(blank_board | mask, 0, true)) then
        imask = compute_required( mask, offset)
        @start_masks[offset] = [ mask, imask, imask | mask ]
      else
        @start_masks[offset] = false
      end
    end
  end

  def compute_required( mask, offset )
    board = blank_board
    0.upto(offset) { | i | board |= 1 << i }
    board |= mask
    return 0 if (!prunable(board | mask, offset))
    board = flood_fill(board,58)
    count = 0
    imask = 0
    0.upto(59) do | i |
      if (board[i] == 0) then
        imask |= (1 << i)
        count += 1
      end
    end
    (count > 0 && count < 5) ? imask : 0
  end

  def flood_fill( board, location)
    return board if (board[location] == 1)
    board |= 1 << location
    row, col = location.divmod(6)
    board = flood_fill( board, location - 1) if (col > 0)
    board = flood_fill( board, location + 1) if (col < 4)
    if (row % 2 == 0) then
      board = flood_fill( board, location - 7) if (col > 0 && row > 0)
      board = flood_fill( board, location - 6) if (row > 0)
      board = flood_fill( board, location + 6) if (row < 9)
      board = flood_fill( board, location + 5) if (col > 0 && row < 9)
    else
      board = flood_fill( board, location - 5) if (col < 4 && row > 0)
      board = flood_fill( board, location - 6) if (row > 0)
      board = flood_fill( board, location + 6) if (row < 9)
      board = flood_fill( board, location + 7) if (col < 4 && row < 9)
    end
    board
  end

  # given a location, produces a list of relative locations covered by the piece at this rotation
  def offsets( location)
    if is_even( location) then
      @even_offsets.collect { | value | value + location }
    else
      @odd_offsets.collect { | value | value + location }
    end
  end

  # returns a set of offsets relative to the top-left most piece of the rotation (by even or odd rows)
  # this is hard to explain. imagine we have this partial board:
  #   0 0 0 0 0 x        [positions 0-5]
  #    0 0 1 1 0 x       [positions 6-11]
  #   0 0 1 0 0 x        [positions 12-17]
  #    0 1 0 0 0 x       [positions 18-23]
  #   0 1 0 0 0 x        [positions 24-29]
  #    0 0 0 0 0 x       [positions 30-35]
  #       ...
  # The top-left of the piece is at position 8, the
  # board would be passed as a set of positions (values array) containing [8,9,14,19,25] not necessarily in that
  # sorted order.  Since that array starts on an odd row, the offsets for an odd row are: [0,1,6,11,17] obtained
  # by subtracting 8 from everything.  Now imagine the piece shifted up and to the right so it's on an even row:
  #   0 0 0 1 1 x        [positions 0-5]
  #    0 0 1 0 0 x       [positions 6-11]
  #   0 0 1 0 0 x        [positions 12-17]
  #    0 1 0 0 0 x       [positions 18-23]
  #   0 0 0 0 0 x        [positions 24-29]
  #    0 0 0 0 0 x       [positions 30-35]
  #       ...
  # Now the positions are [3,4,8,14,19] which after subtracting the lowest value (3) gives [0,1,5,11,16] thus, the
  # offsets for this particular piece are (in even, odd order) [0,1,5,11,16],[0,1,6,11,17] which is what
  # this function would return
  def normalize_offsets( values)
    min = values.min
    even_min = is_even(min)
    other_min = even_min ? min + 6 : min + 7
    other_values = values.collect do | value |
      if is_even(value) then
        value + 6 - other_min
      else
        value + 7 - other_min
      end
    end
    values.collect! { | value | value - min }

    if even_min then
      [values, other_values]
    else
      [other_values, values]
    end
  end

  # produce a bitmask representation of an array of offset locations
  def mask_for_offsets( offsets )
    mask = 0
    offsets.each { | value | mask = mask + ( 1 << value ) }
    mask
  end

  # finds a "safe" position that a position as described by a list of directions can be placed
  # without falling off any edge of the board.  the values returned a location to place the first piece
  # at so it will fit after making the described moves
  def start_adjust( directions )
    south = east = 0;
    directions.each do | direction |
      east += 1 if ( direction == :sw || direction == :nw || direction == :west )
      south += 1 if ( direction == :nw || direction == :ne )
    end
    south * 6 + east
  end

  # given a set of directions places the piece (as defined by a set of directions) on the board at
  # a location that will not take it off the edge
  def get_values ( directions )
    start = start_adjust(directions)
    values = [ start ]
    directions.each do | direction |
      if (start % 12 >= 6) then
        start += @@rotation_odd_adder[direction]
      else
        start += @@rotation_even_adder[direction]
      end
      values += [ start ]
    end

    # some moves take you back to an existing location, we'll strip duplicates
    values.uniq
  end
end

# describes a piece and caches information about its rotations to as to be efficient for iteration
# ATTRIBUTES:
#   rotations -- all the rotations of the piece
#   type -- a numeic "name" of the piece
#   masks -- an array by location of all legal rotational masks (a n inner array) for that location
#   placed -- the mask that this piece was last placed at (not a location, but the actual mask used)
class Piece
  attr_reader :rotations, :type, :masks
  attr_accessor :placed

  # transform hashes that change one direction into another when you either flip or rotate a set of directions
  @@flip_converter = { :west => :west, :east => :east, :nw => :sw, :ne => :se, :sw => :nw, :se => :ne }
  @@rotate_converter = { :west => :nw, :east => :se, :nw => :ne, :ne => :east, :sw => :west, :se => :sw }

  def initialize( directions, type )
    @type = type
    @rotations = Array.new();
    @map = {}

    generate_rotations( directions )
    directions.collect! { | value | @@flip_converter[value] }
    generate_rotations( directions )

    # creates the masks AND a map that returns [location, rotation] for any given mask
    # this is used when a board is found and we want to draw it, otherwise the map is unused
    @masks = Array.new();
    0.upto(59) do | i |
      even = true
      @masks[i] = @rotations.collect do | rotation |
        mask = rotation.start_masks[i]
        @map[mask[0]] = [ i, rotation ] if (mask)
        mask || nil
      end
      @masks[i].compact!
    end
  end

  # rotates a set of directions through all six angles and adds a Rotation to the list for each one
  def generate_rotations( directions )
    6.times do
      rotations.push( Rotation.new(directions))
      directions.collect! { | value | @@rotate_converter[value] }
    end
  end

  # given a board string, adds this piece to the board at whatever location/rotation
  # important: the outbound board string is 5 wide, the normal location notation is six wide (padded)
  def fill_string( board_string)
    location, rotation = @map[@placed]
    rotation.offsets(location).each do | offset |
      row, col = offset.divmod(6)
      board_string[ row*5 + col, 1 ] = @type.to_s
    end
  end
end

# a blank bit board having this form:
#
#    0 0 0 0 0 1
#     0 0 0 0 0 1
#    0 0 0 0 0 1
#     0 0 0 0 0 1
#    0 0 0 0 0 1
#     0 0 0 0 0 1
#    0 0 0 0 0 1
#     0 0 0 0 0 1
#    0 0 0 0 0 1
#     0 0 0 0 0 1
#    1 1 1 1 1 1
#
# where left lest significant bit is the top left and the most significant is the lower right
# the actual board only consists of the 0 places, the 1 places are blockers to keep things from running
# off the edges or bottom
def blank_board
  0b111111100000100000100000100000100000100000100000100000100000100000
end

def full_board
  0b111111111111111111111111111111111111111111111111111111111111111111
end

# determines if a location (bit position) is in an even row
def is_even( location)
  (location % 12) < 6
end

# support function that create three utility maps:
#  $converter -- for each row an array that maps a five bit row (via array mapping)
#                to the a a five bit representation of the bits below it
#  $bit_count -- maps a five bit row (via array mapping) to the number of 1s in the row
#  @@new_regions -- maps a five bit row (via array mapping) to an array of "region" arrays
#                   a region array has three values the first is a mask of bits in the region,
#                   the second is the count of those bits and the third is identical to the first
#                   examples:
#                           0b10010 => [ 0b01100, 2, 0b01100 ], [ 0b00001, 1, 0b00001]
#                           0b01010 => [ 0b10000, 1, 0b10000 ], [ 0b00100, 1, 0b00100 ], [ 0b00001, 1, 0b00001]
#                           0b10001 => [ 0b01110, 3, 0b01110 ]
def create_collector_support
  odd_map = [0b11, 0b110, 0b1100, 0b11000, 0b10000]
  even_map = [0b1, 0b11, 0b110, 0b1100, 0b11000]

  all_odds = Array.new(0b100000)
  all_evens = Array.new(0b100000)
  bit_counts = Array.new(0b100000)
  new_regions = Array.new(0b100000)
  0.upto(0b11111) do | i |
    bit_count = odd = even = 0
    0.upto(4) do | bit |
      if (i[bit] == 1) then
        bit_count += 1
        odd |= odd_map[bit]
        even |= even_map[bit]
      end
    end
    all_odds[i] = odd
    all_evens[i] = even
    bit_counts[i] = bit_count
    new_regions[i] = create_regions( i)
  end

  $converter = []
  10.times { | row | $converter.push((row % 2 == 0) ? all_evens : all_odds) }
  $bit_counts = bit_counts
  $regions = new_regions.collect { | set | set.collect { | value | [ value, bit_counts[value], value] } }
end

# determines if a board is punable, meaning that there is no possibility that it
# can be filled up with pieces.  A board is prunable if there is a grouping of unfilled spaces
# that are not a multiple of five.  The following board is an example of a prunable board:
#    0 0 1 0 0
#     0 1 0 0 0
#    1 1 0 0 0
#     0 1 0 0 0
#    0 0 0 0 0
#       ...
#
# This board is prunable because the top left corner is only 3 bits in area, no piece will ever fit it
# parameters:
#   board -- an initial bit board (6 bit padded rows, see blank_board for format)
#   location -- starting location, everything above and to the left is already full
#   slotting -- set to true only when testing initial pieces, when filling normally
#               additional assumptions are possible
#
# Algorithm:
#    The algorithm starts at the top row (as determined by location) and iterates a row at a time
#    maintainng counts of active open areas (kept in the collector array) each collector contains
#    three values at the start of an iteration:
#          0: mask of bits that would be adjacent to the collector in this row
#          1: the number of bits collected so far
#          2: a scratch space starting as zero, but used during the computation to represent
#             the empty bits in the new row that are adjacent (position 0)
#  The exact procedure is described in-code
def prunable( board, location, slotting = false)
  collectors = []
  # loop accross the rows
  (location / 6).to_i.upto(9) do | row_on |
    # obtain a set of regions representing the bits of the curent row.
    regions = $regions[(board >> (row_on * 6)) & 0b11111]
    converter = $converter[row_on]

    # track the number of collectors at the start of the cycle so that
    # we don't compute against newly created collectors, only existing collectors
    initial_collector_count = collectors.length

    # loop against the regions.  For each region of the row
    # we will see if it connects to one or more existing collectors.
    # if it connects to 1 collector, the bits from the region are added to the
    # bits of the collector and the mask is placed in collector[2]
    # If the region overlaps more than one collector then all the collectors
    # it overlaps with are merged into the first one (the others are set to nil in the array)
    # if NO collectors are found then the region is copied as a new collector
    regions.each do | region |
      collector_found = nil
      region_mask = region[2]
      initial_collector_count.times do | collector_num |
        collector = collectors[collector_num]
        if (collector) then
          collector_mask = collector[0]
          if (collector_mask & region_mask != 0) then
            if (collector_found) then
              collector_found[0] |= collector_mask
              collector_found[1] += collector[1]
              collector_found[2] |= collector[2]
              collectors[collector_num] = nil
            else
              collector_found = collector
              collector[1] += region[1]
              collector[2] |= region_mask
            end
          end
        end
      end
      if (collector_found == nil) then
        collectors.push(Array.new(region))
      end
    end

    # check the existing collectors, if any collector overlapped no bits in the region its [2] value will
    # be zero.  The size of any such reaason is tested if it is not a muliple of five true is returned since
    # the board is prunable.  if it is a multiple of five it is removed.
    # Collector that are still active have a new adjacent value [0] set based n the matched bits
    # and have [2] cleared out for the next cycle.
    collectors.length.times do | collector_num |
      collector = collectors[collector_num]
      if (collector) then
        if (collector[2] == 0) then
          return true if (collector[1] % 5 != 0)
          collectors[collector_num] = nil
        else
          # if a collector matches all bits in the row then we can return unprunable early for the
          # follwing reasons:
          #    1) there can be no more unavailable bits bince we fill from the top left downward
          #    2) all previous regions have been closed or joined so only this region can fail
          #    3) this region must be good since there can never be only 1 region that is nuot
          #       a multiple of five
          # this rule only applies when filling normally, so we ignore the rule if we are "slotting"
          # in pieces to see what configurations work for them (the only other time this algorithm is used).
          return false if (collector[2] == 0b11111 && !slotting)
          collector[0] = converter[collector[2]]
          collector[2] = 0
        end
      end
    end

    # get rid of all the empty converters for the next round
    collectors.compact!
  end
  return false if (collectors.length <= 1) # 1 collector or less and the region is fine
  collectors.any? { | collector | (collector[1] % 5) != 0 } # more than 1 and we test them all for bad size
end

# creates a region given a row mask.  see prunable for what a "region" is
def create_regions( value )
  regions = []
  cur_region = 0
  5.times do | bit |
    if (value[bit] == 0) then
      cur_region |= 1 << bit
    else
      if (cur_region != 0 ) then
        regions.push( cur_region)
        cur_region = 0;
      end
    end
  end
  regions.push(cur_region) if (cur_region != 0)
  regions
end

# find up to the counted number of solutions (or all solutions) and prints the final result
def find_all
  find_top( 1)
  find_top( 0)
  print_results
end

# show the board
def print_results
  print "#{@boards_found} solutions found\n\n"
  print_full_board( @min_board)
  print "\n"
  print_full_board( @max_board)
  print "\n"
end

# finds solutions.  This special version of the main function is only used for the top level
# the reason for it is basically to force a particular ordering on how the rotations are tested for
# the first piece.  It is called twice, first looking for placements of the odd rotations and then
# looking for placements of the even locations.
#
# WHY?
#   Since any found solution has an inverse we want to maximize finding solutions that are not already found
#   as an inverse.  The inverse will ALWAYS be 3 one of the piece configurations that is exactly 3 rotations away
#   (an odd number).  Checking even vs odd then produces a higher probability of finding more pieces earlier
#   in the cycle.  We still need to keep checking all the permutations, but our probability of finding one will
#   diminsh over time.  Since we are TOLD how many to search for this lets us exit before checking all pieces
#   this bennifit is very great when seeking small numbers of solutions and is 0 when looking for more than the
#   maximum number
def find_top( rotation_skip)
  board = blank_board
  (@pieces.length-1).times do
    piece = @pieces.shift
    piece.masks[0].each do | mask, imask, cmask |
      if ((rotation_skip += 1) % 2 == 0) then
        piece.placed = mask
        find( 1, 1, board | mask)
      end
    end
    @pieces.push(piece)
  end
  piece = @pieces.shift
  @pieces.push(piece)
end

# the normail find routine, iterates through the available pieces, checks all rotations at the current location
# and adds any boards found.  depth is acheived via recursion.  the overall approach is described
# here: http://www-128.ibm.com/developerworks/java/library/j-javaopt/
# parameters:
#  start_location -- where to start looking for place for the next piece at
#  placed -- number of pieces placed
#  board -- current state of the board
#
# see in-code comments
def find( start_location, placed, board)
  # find the next location to place a piece by looking for an empty bit
  while board[start_location] == 1
    start_location += 1
  end

  @pieces.length.times do
    piece = @pieces.shift
    piece.masks[start_location].each do | mask, imask, cmask |
      if ( board & cmask == imask) then
        piece.placed = mask
        if (placed == 9) then
          add_board
        else
          find( start_location + 1, placed + 1, board | mask)
        end
      end
    end
    @pieces.push(piece)
  end
end

# print the board
def print_full_board( board_string)
  10.times do | row |
    print " " if (row % 2 == 1)
    5.times do | col |
      print "#{board_string[row*5 + col,1]} "
    end
    print "\n"
  end
end

# when a board is found we "draw it" into a string and then flip that string, adding both to
# the list (hash) of solutions if they are unique.
def add_board
  board_string = "99999999999999999999999999999999999999999999999999"
  @all_pieces.each {  | piece | piece.fill_string( board_string ) }
  save( board_string)
  save( board_string.reverse)
end

# adds a board string to the list (if new) and updates the current best/worst board
def save( board_string)
  if (@all_boards[board_string] == nil) then
    @min_board = board_string if (board_string < @min_board)
    @max_board = board_string if (board_string > @max_board)
    @all_boards.store(board_string,true)
    @boards_found += 1

    # the exit motif is a time saver.  Ideally the function should return, but those tests
    # take noticable time (performance).
    if (@boards_found == @stop_count) then
      print_results
      exit(0)
    end
  end
end


##
## MAIN BODY :)
##
create_collector_support
@pieces = [
  Piece.new( [ :nw, :ne, :east, :east ], 2),
  Piece.new( [ :ne, :se, :east, :ne ], 7),
  Piece.new( [ :ne, :east, :ne, :nw ], 1),
  Piece.new( [ :east, :sw, :sw, :se ], 6),
  Piece.new( [ :east, :ne, :se, :ne ], 5),
  Piece.new( [ :east, :east, :east, :se ], 0),
  Piece.new( [ :ne, :nw, :se, :east, :se ], 4),
  Piece.new( [ :se, :se, :se, :west ], 9),
  Piece.new( [ :se, :se, :east, :se ], 8),
  Piece.new( [ :east, :east, :sw, :se ], 3)
  ];

@all_pieces = Array.new( @pieces)

@min_board = "99999999999999999999999999999999999999999999999999"
@max_board = "00000000000000000000000000000000000000000000000000"
@stop_count = ARGV[0].to_i || 2089
@all_boards = {}
@boards_found = 0

find_all ######## DO IT!!!


before	22.8746228218079
before	23.0593891143799
before	22.9726941585541
before	22.9351620674133
before	22.8476321697235
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	22.666020154953
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	22.6899800300598
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	22.6958730220795
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	22.6892669200897
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	22.6918840408325

-----------------------------------------------------------
so_nbody

# The Computer Language Shootout
# http://shootout.alioth.debian.org
#
# Optimized for Ruby by Jesse Millikan
# From version ported by Michael Neumann from the C gcc version,
# which was written by Christoph Bauer.

SOLAR_MASS = 4 * Math::PI**2
DAYS_PER_YEAR = 365.24

def _puts *args
end

class Planet
 attr_accessor :x, :y, :z, :vx, :vy, :vz, :mass

 def initialize(x, y, z, vx, vy, vz, mass)
  @x, @y, @z = x, y, z
  @vx, @vy, @vz = vx * DAYS_PER_YEAR, vy * DAYS_PER_YEAR, vz * DAYS_PER_YEAR
  @mass = mass * SOLAR_MASS
 end

 def move_from_i(bodies, nbodies, dt, i)
  while i < nbodies
   b2 = bodies[i]
   dx = @x - b2.x
   dy = @y - b2.y
   dz = @z - b2.z

   distance = Math.sqrt(dx * dx + dy * dy + dz * dz)
   mag = dt / (distance * distance * distance)
   b_mass_mag, b2_mass_mag = @mass * mag, b2.mass * mag

   @vx -= dx * b2_mass_mag
   @vy -= dy * b2_mass_mag
   @vz -= dz * b2_mass_mag
   b2.vx += dx * b_mass_mag
   b2.vy += dy * b_mass_mag
   b2.vz += dz * b_mass_mag
   i += 1
  end

  @x += dt * @vx
  @y += dt * @vy
  @z += dt * @vz
 end
end

def energy(bodies)
  e = 0.0
  nbodies = bodies.size

  for i in 0 ... nbodies
    b = bodies[i]
    e += 0.5 * b.mass * (b.vx * b.vx + b.vy * b.vy + b.vz * b.vz)
    for j in (i + 1) ... nbodies
      b2 = bodies[j]
      dx = b.x - b2.x
      dy = b.y - b2.y
      dz = b.z - b2.z
      distance = Math.sqrt(dx * dx + dy * dy + dz * dz)
      e -= (b.mass * b2.mass) / distance
    end
  end
  e
end

def offset_momentum(bodies)
  px, py, pz = 0.0, 0.0, 0.0

  for b in bodies
    m = b.mass
    px += b.vx * m
    py += b.vy * m
    pz += b.vz * m
  end

  b = bodies[0]
  b.vx = - px / SOLAR_MASS
  b.vy = - py / SOLAR_MASS
  b.vz = - pz / SOLAR_MASS
end

BODIES = [
  # sun
  Planet.new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0),

  # jupiter
  Planet.new(
    4.84143144246472090e+00,
    -1.16032004402742839e+00,
    -1.03622044471123109e-01,
    1.66007664274403694e-03,
    7.69901118419740425e-03,
    -6.90460016972063023e-05,
    9.54791938424326609e-04),

  # saturn
  Planet.new(
    8.34336671824457987e+00,
    4.12479856412430479e+00,
    -4.03523417114321381e-01,
    -2.76742510726862411e-03,
    4.99852801234917238e-03,
    2.30417297573763929e-05,
    2.85885980666130812e-04),

  # uranus
  Planet.new(
    1.28943695621391310e+01,
    -1.51111514016986312e+01,
    -2.23307578892655734e-01,
    2.96460137564761618e-03,
    2.37847173959480950e-03,
    -2.96589568540237556e-05,
    4.36624404335156298e-05),

  # neptune
  Planet.new(
    1.53796971148509165e+01,
    -2.59193146099879641e+01,
    1.79258772950371181e-01,
    2.68067772490389322e-03,
    1.62824170038242295e-03,
    -9.51592254519715870e-05,
    5.15138902046611451e-05)
]

init = 200_000 # ARGV[0]
n = Integer(init)

offset_momentum(BODIES)

puts "%.9f" % energy(BODIES)

nbodies = BODIES.size
dt = 0.01

n.times do
  i = 0
  while i < nbodies
    b = BODIES[i]
    b.move_from_i(BODIES, nbodies, dt, i + 1)
    i += 1
  end
end

puts "%.9f" % energy(BODIES)

before	16.2092649936676
before	16.1307928562164
before	16.272579908371
before	16.354877948761
before	16.1989829540253
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	16.8302829265594
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	16.7316989898682
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	17.0103509426117
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	16.9509899616241
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	17.0457820892334

-----------------------------------------------------------
so_nested_loop

#!/usr/bin/ruby
# -*- mode: ruby -*-
# $Id: nestedloop-ruby.code,v 1.4 2004/11/13 07:42:22 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/
# from Avi Bryant

n = 16 # Integer(ARGV.shift || 1)
x = 0
n.times do
    n.times do
        n.times do
            n.times do
                n.times do
                    n.times do
                        x += 1
                    end
                end
            end
        end
    end
end
# puts x



before	6.04620599746704
before	6.38746809959412
before	6.01532006263733
before	6.06894493103027
before	5.84608101844788
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.31685614585876
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.32196092605591
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.32922196388245
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.33552289009094
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.28663897514343

-----------------------------------------------------------
so_nsieve

# The Computer Language Shootout
# http://shootout.alioth.debian.org/
#
# contributed by Glenn Parker, March 2005
# modified by Evan Phoenix, Sept 2006

def sieve(m)
  flags = Flags.dup[0,m]
  count = 0
  pmax = m - 1
  p = 2
  while p <= pmax
    unless flags[p].zero?
      count += 1
      mult = p
      while mult <= pmax
        flags[mult] = 0
        mult += p
      end
    end
    p += 1
  end
  count
end

n = 9 # (ARGV[0] || 2).to_i
Flags = ("\x1" * ( 2 ** n * 10_000)).unpack("c*")

n.downto(n-2) do |exponent|
  break if exponent < 0
  m = (1 << exponent) * 10_000
  # m = (2 ** exponent) * 10_000
  count = sieve(m)
  printf "Primes up to %8d %8d\n", m, count
end

before	13.7914230823517
before	13.922590970993
before	14.5630271434784
before	14.3610351085663
before	14.2760078907013
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	15.0021541118622
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	14.9635682106018
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	15.108903169632
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	15.2680888175964
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	15.1050460338593

-----------------------------------------------------------
so_nsieve_bits

#!/usr/bin/ruby
#
# The Great Computer Language Shootout
# http://shootout.alioth.debian.org/
#
# nsieve-bits in Ruby
# Contributed by Glenn Parker, March 2005

CharExponent = 3
BitsPerChar = 1 << CharExponent
LowMask = BitsPerChar - 1

def sieve(m)
  items = "\xFF" * ((m / BitsPerChar) + 1)
  masks = ""
  BitsPerChar.times do |b|
    masks << (1 << b).chr
  end

  count = 0
  pmax = m - 1
  2.step(pmax, 1) do |p|
    if items[p >> CharExponent][p & LowMask] == 1
      count += 1
      p.step(pmax, p) do |mult|
	a = mult >> CharExponent
	b = mult & LowMask
	items[a] -= masks[b] if items[a][b] != 0
      end
    end
  end
  count
end

n = 9 # (ARGV[0] || 2).to_i
n.step(n - 2, -1) do |exponent|
  break if exponent < 0
  m = 2 ** exponent * 10_000
  count = sieve(m)
  printf "Primes up to %8d %8d\n", m, count
end


before	14.3027591705322
before	14.5675277709961
before	14.3442149162292
before	14.5829401016235
before	14.3769559860229
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	13.4831960201263
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	13.7394449710846
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	13.7666640281677
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	13.4597060680389
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	13.7369830608368

-----------------------------------------------------------
so_object

#!/usr/bin/ruby
# -*- mode: ruby -*-
# $Id: objinst-ruby.code,v 1.4 2004/11/13 07:42:25 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/
# with help from Aristarkh Zagorodnikov

class Toggle
    def initialize(start_state)
        @bool = start_state
    end

    def value
        @bool
    end

    def activate
        @bool = !@bool
        self
    end
end

class NthToggle < Toggle
    def initialize(start_state, max_counter)
        super start_state
        @count_max = max_counter
        @counter = 0
    end

    def activate
        @counter += 1
        if @counter >= @count_max
            @bool = !@bool
            @counter = 0
        end
        self
    end
end

n = 1500000 # (ARGV.shift || 1).to_i

toggle = Toggle.new 1
5.times do
    toggle.activate.value ? 'true' : 'false'
end
n.times do
    toggle = Toggle.new 1
end

ntoggle = NthToggle.new 1, 3
8.times do
    ntoggle.activate.value ? 'true' : 'false'
end
n.times do
    ntoggle = NthToggle.new 1, 3
end


before	4.00634002685547
before	3.99505496025085
before	3.91797113418579
before	4.07280278205872
before	3.90857005119324
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.05579900741577
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.02142000198364
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.0338249206543
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.19822287559509
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.27065896987915

-----------------------------------------------------------
so_partial_sums

n = 2_500_000 # (ARGV.shift || 1).to_i

alt = 1.0 ; s0 = s1 = s2 = s3 = s4 = s5 = s6 = s7 = s8 = 0.0

1.upto(n) do |d|
  d = d.to_f ; d2 = d * d ; d3 = d2 * d ; ds = Math.sin(d) ; dc = Math.cos(d)

  s0 += (2.0 / 3.0) ** (d - 1.0)
  s1 += 1.0 / Math.sqrt(d)
  s2 += 1.0 / (d * (d + 1.0))
  s3 += 1.0 / (d3 * ds * ds)
  s4 += 1.0 / (d3 * dc * dc)
  s5 += 1.0 / d
  s6 += 1.0 / d2
  s7 += alt / d
  s8 += alt / (2.0 * d - 1.0)

  alt = -alt
end

if false
  printf("%.9f\t(2/3)^k\n", s0)
  printf("%.9f\tk^-0.5\n", s1)
  printf("%.9f\t1/k(k+1)\n", s2)
  printf("%.9f\tFlint Hills\n", s3)
  printf("%.9f\tCookson Hills\n", s4)
  printf("%.9f\tHarmonic\n", s5)
  printf("%.9f\tRiemann Zeta\n", s6)
  printf("%.9f\tAlternating Harmonic\n", s7)
  printf("%.9f\tGregory\n", s8)
end

before	22.8626010417938
before	22.8569779396057
before	22.7499258518219
before	23.8781361579895
before	22.7290558815002
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	22.6856310367584
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	22.7475590705872
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	22.5537869930267
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	22.8313889503479
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	22.6039428710938

-----------------------------------------------------------
so_pidigits

# The Great Computer Language Shootout
# http://shootout.alioth.debian.org/
#
# contributed by Gabriele Renzi

class PiDigitSpigot

    def initialize()
        @z = Transformation.new 1,0,0,1
        @x = Transformation.new 0,0,0,0
        @inverse = Transformation.new 0,0,0,0
    end

    def next!
        @y = @z.extract(3)
        if safe? @y
            @z = produce(@y)
            @y
        else
            @z = consume @x.next!()
            next!()
        end
    end

    def safe?(digit)
        digit == @z.extract(4)
    end

    def produce(i)
        @inverse.qrst(10,-10*i,0,1).compose(@z)
    end

    def consume(a)
        @z.compose(a)
    end
end


class Transformation
    attr_reader :q, :r, :s, :t
    def initialize (q, r, s, t)
        @q,@r,@s,@t,@k = q,r,s,t,0
    end

    def next!()
        @q = @k = @k + 1
        @r = 4 * @k + 2
        @s = 0
        @t = 2 * @k + 1
        self
    end

    def extract(j)
        (@q * j + @r) / (@s * j + @t)
    end

    def compose(a)
        self.class.new( @q * a.q,
                        @q * a.r + r * a.t,
                        @s * a.q + t * a.s,
                        @s * a.r + t * a.t
                    )
    end

    def qrst *args
        initialize *args
        self
    end


end


WIDTH = 10
n = 2_500 # Integer(ARGV[0])
j = 0

digits = PiDigitSpigot.new

while n > 0
    if n >= WIDTH
        WIDTH.times {print digits.next!}
        j += WIDTH
    else
        n.times {print digits.next!}
        (WIDTH-n).times {print " "}
        j += n
    end
    puts "\t:"+j.to_s
    n -= WIDTH
end


before	5.36250996589661
before	5.35777997970581
before	5.40804386138916
before	5.31864190101624
before	5.33629894256592
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.33258986473083
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.36751890182495
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.49011206626892
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.33930087089539
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.40085697174072

-----------------------------------------------------------
so_random

# from http://www.bagley.org/~doug/shootout/bench/random/random.ruby

IM = 139968.0
IA = 3877.0
IC = 29573.0

$last = 42.0

def gen_random(max)
  (max * ($last = ($last * IA + IC) % IM)) / IM
end

N = 1000000

i=0
while i<N
  i+=1
  gen_random(100.0)
end
# "%.9f" % gen_random(100.0)

before	1.3261878490448
before	1.32623100280762
before	1.30794596672058
before	1.30072498321533
before	1.31149697303772
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.36152291297913
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.35794186592102
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.35548806190491
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.4818480014801
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.35265493392944

-----------------------------------------------------------
so_reverse_complement

#!/usr/bin/ruby
# The Great Computer Language Shootout
# http://shootout.alioth.debian.org/
#
# Contributed by Peter Bjarke Olsen
# Modified by Doug King

seq=Array.new

def revcomp(seq)
  seq.reverse!.tr!('wsatugcyrkmbdhvnATUGCYRKMBDHVN','WSTAACGRYMKVHDBNTAACGRYMKVHDBN')
  stringlen=seq.length
  0.step(stringlen-1,60) {|x| print seq.slice(x,60) , "\n"}
end

input = open(File.join(File.dirname($0), 'fasta.output.2500000'), 'rb')

while input.gets
  if $_ =~ />/
    if seq.length != 0
      revcomp(seq.join)
      seq=Array.new
    end
    puts $_
  else
    $_.sub(/\n/,'')
    seq.push $_
  end
end
revcomp(seq.join)

before	5.5645489692688
before	5.63810300827026
before	5.60752892494202
before	5.60121297836304
before	5.68193197250366
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.6479651927948
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.59674501419067
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.5693371295929
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.54592800140381
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.58488607406616

-----------------------------------------------------------
so_sieve

# from http://www.bagley.org/~doug/shootout/bench/sieve/sieve.ruby
num = 40
count = i = j = 0
flags0 = Array.new(8192,1)
k = 0
while k < num
  k+=1
  count = 0
  flags = flags0.dup
  i = 2
  while i<8192
    i+=1
    if flags[i]
      # remove all multiples of prime: i
      j = i*i
      while j < 8192
        j += i
        flags[j] = nil
      end
      count += 1
    end
  end
end
count

before	0.561233043670654
before	0.390736103057861
before	0.395308971405029
before	0.393702983856201
before	0.390278100967407
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.371313095092773
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.370090007781982
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.365416049957275
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.364776134490967
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	0.370437860488892

-----------------------------------------------------------
so_spectralnorm

# The Computer Language Shootout
# http://shootout.alioth.debian.org/
# Contributed by Sokolov Yura

def eval_A(i,j)
	return 1.0/((i+j)*(i+j+1)/2+i+1)
end

def eval_A_times_u(u)
        v, i = nil, nil
	(0..u.length-1).collect { |i|
                v = 0
		for j in 0..u.length-1
			v += eval_A(i,j)*u[j]
                end
                v
        }
end

def eval_At_times_u(u)
	v, i = nil, nil
	(0..u.length-1).collect{|i|
                v = 0
		for j in 0..u.length-1
			v += eval_A(j,i)*u[j]
                end
                v
        }
end

def eval_AtA_times_u(u)
	return eval_At_times_u(eval_A_times_u(u))
end

n = 500 # ARGV[0].to_i

u=[1]*n
for i in 1..10
        v=eval_AtA_times_u(u)
        u=eval_AtA_times_u(v)
end
vBv=0
vv=0
for i in 0..n-1
        vBv += u[i]*v[i]
        vv += v[i]*v[i]
end

str = "%0.9f" % (Math.sqrt(vBv/vv)), "\n"
# print str

before	15.5464689731598
before	15.2704830169678
before	15.3095099925995
before	15.1492869853973
before	15.2364990711212
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	15.6332969665527
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	15.6609981060028
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	15.3393859863281
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	15.6616930961609
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	15.5565891265869

-----------------------------------------------------------
vm1_block

def m
  yield
end

i=0
while i<30000000 # while loop 1
  i+=1
  m{
  }
end

before	11.5795950889587
before	11.7277939319611
before	11.580726146698
before	11.4409210681915
before	11.9388749599457
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	11.7785060405731
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	11.9361248016357
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	11.7688918113708
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	11.2702820301056
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	11.5698080062866

-----------------------------------------------------------
vm1_const

Const = 1

i = 0
while i<30000000 # while loop 1
  i+= 1
  j = Const
  k = Const
end

before	5.56023907661438
before	5.61559987068176
before	5.64688515663147
before	5.56939101219177
before	5.5691089630127
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.58550095558167
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.59849095344543
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.6021740436554
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.56811094284058
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.49515390396118

-----------------------------------------------------------
vm1_ensure

i=0
while i<30000000 # benchmark loop 1
  i+=1
  begin
    begin
    ensure
    end
  ensure
  end
end


before	3.0959529876709
before	5.57623291015625
before	3.33014392852783
before	3.09027886390686
before	3.44372010231018
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.41296315193176
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.38468194007874
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.55707883834839
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.48767781257629
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.41675710678101

-----------------------------------------------------------
vm1_ivar

@a = 1

i = 0
while i<30000000 # while loop 1
  i+= 1
  j = @a
  k = @a
end

before	6.22526717185974
before	6.13226318359375
before	6.20852398872375
before	6.16846203804016
before	6.13179206848145
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	7.38351106643677
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	7.53921413421631
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	7.42088913917542
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	7.20302700996399
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	7.58444285392761

-----------------------------------------------------------
vm1_ivar_set

i = 0
while i<30_000_000 # while loop 1
  i+= 1
  @a = 1
  @b = 2
end

before	6.2111291885376
before	6.25323700904846
before	6.23472309112549
before	6.37576484680176
before	6.24183797836304
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.38076996803284
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.2780499458313
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.26059699058533
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.2370138168335
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.24652600288391

-----------------------------------------------------------
vm1_length

a = 'abc'
b = [1, 2, 3]
i=0
while i<30000000 # while loop 1
  i+=1
  a.length
  b.length
end


before	5.66836810112
before	5.68769884109497
before	5.72738409042358
before	5.86627197265625
before	5.73555779457092
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.55205297470093
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.8344509601593
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.60370898246765
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.79008889198303
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.92835283279419

-----------------------------------------------------------
vm1_neq

i = 0
obj1 = Object.new
obj2 = Object.new

while i<30000000 # while loop 1
  i+= 1
  obj1 != obj2
end

before	4.97074604034424
before	4.85829305648804
before	4.99582290649414
before	4.97255301475525
before	4.93630909919739
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.90661597251892
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.79184293746948
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.81187009811401
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.87827706336975
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.82643699645996

-----------------------------------------------------------
vm1_not

i = 0
obj = Object.new

while i<30000000 # while loop 1
  i+= 1
  !obj
end

before	4.16578578948975
before	4.15985608100891
before	4.11895799636841
before	4.10741305351257
before	4.0618360042572
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.2041871547699
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.2647762298584
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.1045389175415
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.10836386680603
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	6.38489007949829

-----------------------------------------------------------
vm1_rescue

i=0
while i<30000000 # while loop 1
  i+=1
  begin
  rescue
  end
end

before	3.28790092468262
before	3.50665307044983
before	3.5161988735199
before	3.22473192214966
before	3.43456482887268
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.25899910926819
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.2798490524292
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.20230197906494
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.26448392868042
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.24454617500305

-----------------------------------------------------------
vm1_simplereturn

def m
  return 1
end
i=0
while i<30000000 # while loop 1
  i+=1
  m
end


before	9.2456579208374
before	9.27782893180847
before	9.28710985183716
before	9.11728882789612
before	9.20839810371399
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	9.76113605499268
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	9.6539990901947
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	9.70153403282166
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	9.45405292510986
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	9.50084400177002

-----------------------------------------------------------
vm1_swap

a = 1
b = 2
i=0
while i<30000000 # while loop 1
  i+=1
  a, b = b, a
end


before	4.34666395187378
before	4.26381802558899
before	4.11824607849121
before	4.32778310775757
before	4.25516605377197
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.18974685668945
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.14348793029785
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.31321501731873
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.16265606880188
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.23358297348022

-----------------------------------------------------------
vm2_array

i=0
while i<6000000 # benchmark loop 2
  i+=1
  a = [1,2,3,4,5,6,7,8,9,10]
end

before	3.87851810455322
before	3.97157096862793
before	3.88191890716553
before	3.91899800300598
before	3.90684700012207
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.73879599571228
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.74566411972046
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.84029197692871
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.720703125
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.88692593574524

-----------------------------------------------------------
vm2_case

i=0
while i<6000000 # while loop 2
  case :foo
  when :bar
    raise
  when :baz
    raise
  when :boo
    raise
  when :foo
    i+=1
  end
end


before	1.32370615005493
before	1.35075712203979
before	1.31182384490967
before	1.3103289604187
before	1.32275295257568
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.34642696380615
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.37388706207275
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.35846996307373
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.34257507324219
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.36211109161377

-----------------------------------------------------------
vm2_eval

i=0
while i<6000000 # benchmark loop 2
  i+=1
  eval("1")
end


before	73.9543449878693
before	73.703094959259
before	74.1844069957733
before	73.9121189117432
before	74.1831691265106
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	73.6112089157104
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	74.1668598651886
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	74.089339017868
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	74.1335561275482
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	73.9861071109772

-----------------------------------------------------------
vm2_method

def m
  nil
end

i=0
while i<6000000 # benchmark loop 2
  i+=1
  m; m; m; m; m; m; m; m;
end

before	8.40255618095398
before	8.27722096443176
before	8.69953393936157
before	8.39002299308777
before	8.73739981651306
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	8.96812391281128
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	9.14253306388855
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	8.9731981754303
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	9.04129886627197
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	8.97750186920166

-----------------------------------------------------------
vm2_mutex

require 'thread'

m = Mutex.new

i=0
while i<6000000 # benchmark loop 2
  i+=1
  m.synchronize{}
end

before	8.0807089805603
before	8.05802702903748
before	7.92139482498169
before	7.83855581283569
before	7.93689894676208
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	7.14875316619873
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	7.16029095649719
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	7.14486813545227
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	7.11287999153137
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	7.26383209228516

-----------------------------------------------------------
vm2_poly_method

class C1
  def m
    1
  end
end
class C2
  def m
    2
  end
end

o1 = C1.new
o2 = C2.new

i=0
while i<6000000 # benchmark loop 2
  o = (i % 2 == 0) ? o1 : o2
  o.m; o.m; o.m; o.m; o.m; o.m; o.m; o.m
  i+=1
end

before	12.3205499649048
before	12.4570882320404
before	12.4130427837372
before	12.5863678455353
before	13.3297801017761
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	11.0173962116241
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	10.9880268573761
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	10.9633560180664
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	10.9702548980713
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	10.9755148887634

-----------------------------------------------------------
vm2_poly_method_ov

class C1
  def m
    1
  end
end
class C2
  def m
    2
  end
end

o1 = C1.new
o2 = C2.new

i=0
while i<6000000 # benchmark loop 2
  o = (i % 2 == 0) ? o1 : o2
#  o.m; o.m; o.m; o.m; o.m; o.m; o.m; o.m
  i+=1
end

before	1.43685603141785
before	1.5377151966095
before	1.45677995681763
before	1.44273900985718
before	1.50195002555847
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.57257199287415
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.52090907096863
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.552983045578
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.50544595718384
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	1.54216194152832

-----------------------------------------------------------
vm2_proc

def m &b
  b
end

pr = m{
  a = 1
}

i=0
while i<6000000 # benchmark loop 2
  i+=1
  pr.call
end


before	3.34935879707336
before	3.44431591033936
before	3.33672094345093
before	3.51050281524658
before	3.56756591796875
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.4562840461731
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.65186810493469
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.40419602394104
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.4401650428772
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.52638602256775

-----------------------------------------------------------
vm2_regexp

i=0
str = 'xxxhogexxx'
while i<6000000 # benchmark loop 2
  /hoge/ =~ str
  i+=1
end

before	5.29443597793579
before	5.29413104057312
before	5.29894518852234
before	5.47156715393066
before	5.19227886199951
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.39444184303284
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.28441214561462
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.47036099433899
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.49380612373352
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	5.53930401802063

-----------------------------------------------------------
vm2_send

class C
  def m
  end
end

o = C.new

i=0
while i<6000000 # benchmark loop 2
  i+=1
  o.__send__ :m
end

before	1.84811210632324
before	1.86897587776184
before	1.87477684020996
before	1.9931058883667
before	1.84342908859253
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.38866400718689
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.40415787696838
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.42585897445679
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.4746630191803
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.49876809120178

-----------------------------------------------------------
vm2_super


class C
  def m
    1
  end
end

class CC < C
  def m
    super()
  end
end

obj = CC.new

i = 0
while i<6000000 # benchmark loop 2
  obj.m
  i+=1
end

before	2.74533605575562
before	2.71221113204956
before	2.70381593704224
before	2.70965600013733
before	2.73880505561829
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.77874898910522
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.78064513206482
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.78571391105652
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.82608699798584
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.72219395637512

-----------------------------------------------------------
vm2_unif1

i = 0
def m a, b
end

while i<6000000 # benchmark loop 2
  i+=1
  m 100, 200
end

before	1.67015409469604
before	1.71999001502991
before	1.76372694969177
before	1.66402292251587
before	1.63081407546997
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.15409898757935
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.1948869228363
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.18906188011169
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.16617894172668
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.2821409702301

-----------------------------------------------------------
vm2_zsuper

i = 0

class C
  def m a
    1
  end
end

class CC < C
  def m a
    super
  end
end

obj = CC.new

while i<6000000 # benchmark loop 2
  obj.m 10
  i+=1
end

before	2.7700982093811
before	2.96294021606445
before	2.86855101585388
before	3.00642395019531
before	2.8550980091095
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.94186401367188
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.94587302207947
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.98980712890625
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.87220501899719
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	2.92531299591064

-----------------------------------------------------------
vm3_gc

#! /usr/bin/ruby
5000.times do
  100.times do
    {"xxxx"=>"yyyy"}
  end
  GC.start
end

before	3.1406090259552
before	3.11142301559448
before	3.12758994102478
before	3.09364914894104
before	3.1346697807312
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.11939692497253
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.11997103691101
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.10864496231079
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.19296622276306
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	3.15364980697632

-----------------------------------------------------------
vm3_thread_create_join

i=0
while i<100_000 # benchmark loop 3
  i+=1
  Thread.new{
  }.join
end

before	4.17071413993835
before	4.1967978477478
before	4.22113585472107
before	4.23371601104736
before	4.35664010047913
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.30672311782837
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.20961403846741
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.18438911437988
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.18869686126709
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	4.22895503044128

-----------------------------------------------------------
vm3_thread_mutex

require 'thread'
m = Mutex.new
r = 0
max = 1000
(1..max).map{
  Thread.new{
    i=0
    while i<max
      i+=1
      m.synchronize{
        r += 1
      }
    end
  }
}.each{|e|
  e.join
}
raise r.to_s if r != max * max

before	39.7091739177704
before	76.8955149650574
before	96.9586091041565
before	51.4148449897766
before	54.8269529342651
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	86.3939781188965
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	44.7064459323883
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	65.640771150589
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	57.5394620895386
ruby 1.9.2dev (2010-01-04 trunk 26238) [i686-linux]	59.3028700351715

-----------------------------------------------------------
raw data:

In This Thread