Charles Nutter wrote:
JRuby benchmarking:
* Use Java 6+
Java 6 is much faster than Java 5. Java 7 is faster still in many cases.
* Pass --server if -v output says "client" VM
I didn't consider it because the behavior I showed looks wrong for
either Java 5 or Java 6 in either client or server mode. Indeed I
obtained the same results with Java 6 Server VM.
A computation split into two parallel threads takes more time than the
same computation with one thread. 'top' reports 185% CPU and 100% CPU
respectively.
I was not concerned with comparing MRI and jruby. MRI was a baseline
to demonstrate that Pure's parallelism was working in the first place.
I was unable to find your eaa9e7f commit so I grabbed the latest
master branch.
jruby 1.5.0.dev (ruby 1.8.7 patchlevel 174) (2009-11-02 55366a1) (Java
HotSpot(TM) 64-Bit Server VM 1.6.0_15) [x86_64-java]
Core 2 Duo 1.83GHz; all apps closed except Terminal; benchmarks made
without 'top' running.
Rehearsal ------------------------------------------------------------
1 thread, 1 interpreter 3.422000 0.000000 3.422000 ( 3.422000)
2 threads, 1 interpreter 4.008000 0.000000 4.008000 ( 4.008000)
--------------------------------------------------- total: 7.430000sec
user system total real
1 thread, 1 interpreter 2.942000 0.000000 2.942000 ( 2.942000)
2 threads, 1 interpreter 3.595000 0.000000 3.595000 ( 3.595000)
Results are the same with Pure removed:
require 'benchmark'
def left
(1..10_000_000).inject(0) { |acc, n| acc + n }
end
def right
(1..10_000_000).inject(0) { |acc, n| acc + n }
end
Benchmark.bmbm { |bm|
bm.report("1 thread") {
Thread.new {
[left, right]
}.value
}
bm.report("2 threads") {
[
Thread.new { left },
Thread.new { right },
].map { |t| t.value }
}
}
Rehearsal ---------------------------------------------
1 thread 6.726000 0.000000 6.726000 ( 6.726000)
2 threads 7.478000 0.000000 7.478000 ( 7.478000)
----------------------------------- total: 14.204000sec
user system total real
1 thread 6.636000 0.000000 6.636000 ( 6.636000)
2 threads 8.196000 0.000000 8.196000 ( 8.196000)
···
--
Posted via http://www.ruby-forum.com/\.