[#43767] UDP通信時のエラー検出 — "中田雅美" <mimiger2007@...>
中田(雅)と申します。
小西 弘将です。
In message <6DC7D411CB0FB4konishi@raax.co.jp>
中田(雅)です。
In message <407af920708010215n6cb6a4a7o32a164da7d0b6901@mail.gmail.com> 2007-08-01T18:15+0900,
こんにちは。
[#43777] gsub! で定数を書き換えられてしまう — 古川大輔 <mogya99@...>
はじめまして。もぎゃ と申します。
[#43781] WEB公開されるML投稿記事について — REI OKAMOTO <okamoto@...>
昨日投稿した岡本です。
[#43796] mod_ruby 環境の Rails での日本語文字列の truncate — "IKEDA Katsumi" <ikedak@...8.so-net.ne.jp>
池田と申します。
[#43806] Procの仕様について — "SHIMADA Koji" <snoozer.05@...>
しまだです。
[#43809] 配列についての質問 — "142QN4969@..." <ohrsts@...>
小原です。御世話になっています。
[#43815] 日本Rubyの会のHPでHikiError — "SHIMADA Koji" <snoozer.05@...>
しまだです。
[#43833] JRubyからWin32OLEの使用 — "kouichi ueno" <koichiarchi@...>
上野です。
[#43846] 質問:シェルスクリプトにすると uninitialized constant DATA — sw@...
環境は Windows XP
なかだです。
コメント、ありがとうございます。
[#43857] Hashへの生成順は保障されないのか? — Hiroshi Kasamatsu <qqmn89yb9@...>
こんにちは、笠松と申します。
Hiroshi Kasamatsu wrote:
皆さん、早速のレスありがとうございます。
Hiroshi Kasamatsu wrote:
Urabeさん、笠松です。レスありがとうございます。
Hiroshi Kasamatsu wrote:
cuzic です。
cuzic wrote:
In article <46C9E7BB.4060100@ruby-lang.org>,
おお、田中さんを満足させる説明ってのは結構ハードル高そうだな。
# 出遅れたので、レスすべきメールが判らなくなってしまったので、手近なのに
まつもと ゆきひろです
なかだです。
ささだです。
まつもと ゆきひろです
なかだです。
At Tue, 21 Aug 2007 13:59:43 +0900,
ささだです。
At Tue, 21 Aug 2007 19:29:11 +0900,
In article <86sl6dgikh.knu@iDaemons.org>,
In article <87zm0kaz60.fsf@fsij.org>,
前田です。
Yuguiといいます。
まつもと ゆきひろです
大久保といいます。Ruby初心者ですがよろしくお願いします。
ささだです。
[#43868] ruby1.8でssl通信@stmp/pop3 — "Tomo Matsumoto" <tomoyuki28jp@...>
松本と申します。
[#43923] [ANN] isi-1.1.3 released! — NISHIMATSU Takeshi <t_nissie@...>
西松と申します。
[#43939] Windows で正確なファイル名を取得するには — Five point Five <5.5@...>
Five point Five です。
[ruby-list:43887] Re: Hashへの生成順は保障されないのか?
なかだです。
At Tue, 21 Aug 2007 07:46:20 +0900,
Yukihiro Matsumoto wrote in [ruby-list:43879]:
> 実は私自身はHashの順序の保存については積極的に反対しているわ
> けではないのです。しかし、
>
> * 一般的にはHashの順序が保存されない
> * どの順序が最適かは実は一意に決まらない(ような気がする)
「どの順序」と選べるほど選択肢はないような気がするのですが。
> * 順序の保存によってHashの効率が下がるのはうれしくない
[ruby-dev:24569]を1.9最新用に直して、Hal Fultonから送られてきた
ベンチマークを試してみました。
http://www.rubyist.net/~nobu/ruby/ordered-hash-1.9.diff
http://www.rubyist.net/~nobu/ruby/ordered-hash-1.8.diff
予想通りdeleteがやや遅くなっていますが、思ったほどの影響はないよ
うです。逆にeachやsort_byが速くなっているのは、二重配列から単純
なdouble linked listをたどるようになっているのが大きいのかもしれ
ません。
前
add to empty hash 0.650000 0.010000 0.660000 ( 0.654691)
add to hash with 100000 elements 0.710000 0.020000 0.730000 ( 0.730761)
each_key with 200000 elements 0.050000 0.000000 0.050000 ( 0.053228)
keys.sort_by.each, 200000 elements 1.150000 0.000000 1.150000 ( 1.159369)
delete 100000 times, non-existing key 0.040000 0.000000 0.040000 ( 0.034815)
delete 100000 times, existing keys 0.260000 0.000000 0.260000 ( 0.256023)
include? 100000 times, non-existing key 0.050000 0.000000 0.050000 ( 0.046105)
include? 100000 times, existing keys 0.230000 0.000000 0.230000 ( 0.225641)
clear hash with 100000 elements 0.030000 0.000000 0.030000 ( 0.037633)
後
user system total real
add to empty hash 0.550000 0.020000 0.570000 ( 0.558828)
add to hash with 100000 elements 0.620000 0.010000 0.630000 ( 0.636749)
each_key with 200000 elements 0.040000 0.000000 0.040000 ( 0.043783)
keys.sort_by.each, 200000 elements 0.270000 0.010000 0.280000 ( 0.276364)
delete 100000 times, non-existing key 0.030000 0.000000 0.030000 ( 0.035522)
delete 100000 times, existing keys 0.270000 0.000000 0.270000 ( 0.265942)
include? 100000 times, non-existing key 0.030000 0.000000 0.030000 ( 0.028704)
include? 100000 times, existing keys 0.190000 0.000000 0.190000 ( 0.193877)
clear hash with 100000 elements 0.040000 0.000000 0.040000 ( 0.035513)
--
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
中田 伸悦
Attachments (1)
# Hash benchmarking suite
# by Ryan Leavengood
require 'benchmark'
class SymbolGen
def initialize(value='aaaaaaaa')
@value = value
end
def generate
result = @value.intern
@value = @value.succ
result
end
end
if $0 == __FILE__
sg = SymbolGen.new
h = {}
iterations = 100000
Benchmark.bm(40) do |bx|
block = proc { h[sg.generate] = sg.generate }
bx.report("add to empty hash") { iterations.times &block }
bx.report("add to hash with #{iterations} elements") { iterations.times &block }
bx.report("each_key with #{2*iterations} elements") { h.each_key {|key|} }
bx.report("keys.sort_by.each, #{2*iterations} elements") { h.keys.sort_by{|k| k.to_s}.each {|key|} }
bx.report("delete #{iterations} times, non-existing key") { iterations.times { h.delete(:not_a_key) } }
sg2 = SymbolGen.new
bx.report("delete #{iterations} times, existing keys") { iterations.times { h.delete(sg2.generate); sg2.generate } }
bx.report("include? #{iterations} times, non-existing key") { iterations.times { h.include?(:not_a_key) } }
bx.report("include? #{iterations} times, existing keys") { iterations.times { h.include?(sg2.generate); sg2.generate } }
bx.report("clear hash with #{iterations} elements") { h.clear }
end
end