ちなみに

火曜日の空は僕を押しつぶした。

2008-12-18から1日間の記事一覧

非同期ブームに乗って非同期mapを考えてみた

require 'benchmark' module Enumerable def amap map {|e| Thread.new { yield e } }.map(&:value) end end ary = [1, 2, 3, 4, 5] res = {} Benchmark.bm(4) do |x| x.report('map') { res[:map] = ary.map {|e| sleep 1; e } } x.report('amap') { res[:a…