From: James Gray Date: 2009-01-20T22:49:59+09:00 Subject: [ruby-core:21461] Re: Array concat loops sometimes taking large amounts of "system" time. On Jan 20, 2009, at 6:48 AM, Ron Mayer wrote: > a = [1,2,3,4,5]; > b=[]; > puts Benchmark.measure{ (1..10000000).each{b.concat(a)}} This code slowly builds up a very large Array: >> a = (1..5).to_a => [1, 2, 3, 4, 5] >> b = [ ] => [] >> b.concat(a) => [1, 2, 3, 4, 5] >> b.concat(a) => [1, 2, 3, 4, 5, 1, 2, 3, 4, 5] The time loss may come from memory allocation. James Edward Gray II