Java List to Ruby Array conversion ~100% slower than primitive array conversion
-------------------------------------------------------------------------------

                 Key: JRUBY-3910
                 URL: http://jira.codehaus.org/browse/JRUBY-3910
             Project: JRuby
          Issue Type: Improvement
          Components: Performance
    Affects Versions: JRuby 1.3.1, JRuby 1.4
         Environment: MacOSX 10.5.8
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03-211)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02-83, mixed mode)
            Reporter: Michael Rykov
             Fix For: JRuby 1.4, JRuby 1.3.1
         Attachments: bench.rb

On both jRuby 1.3.1 and jRuby 1.4 (edge), I found that converting Java Lists to 
Ruby Array actually performs worse than converting the Java List to a Java 
Array to a Ruby Array.  Performance of the 2-step conversion is up to 50% 
faster.

Here are the results

{code}
$ jruby -v      
jruby 1.4.0dev (ruby 1.8.7p174) (2009-08-23 6f772bf) (Java HotSpot(TM) 64-Bit 
Server VM 1.6.0_13) [x86_64-java]
$ jruby --server ./bench.rb 
Rehearsal -----------------------------------------------------
        list.to_a   2.996000   0.000000   2.996000 (  2.841000)
list.toArray.to_a   1.821000   0.000000   1.821000 (  1.821000)
       array.to_a   0.772000   0.000000   0.772000 (  0.772000)
-------------------------------------------- total: 5.589000sec

                        user     system      total        real
        list.to_a   1.875000   0.000000   1.875000 (  1.875000)
list.toArray.to_a   0.916000   0.000000   0.916000 (  0.916000)
       array.to_a   0.760000   0.000000   0.760000 (  0.760000)

{code}

Knowing this was really helpful in getting my Google App Engine application to 
stop hitting the request time limit when loading arrays from the Datastore 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to