I've been running a few tests. JI performance stinks pretty bad.
Here's numbers from the existing test, which takes two byteslists via JI
and appends one to the other. No new objects created, other than
internally the array for the bytelist growing. And performance isn't too
bad, about 2x a normal String append which is theoretically the same
amount of work.
Measure bytelist appends (via Java integration)
1.556000 0.000000 1.556000 ( 1.555000)
1.268000 0.000000 1.268000 ( 1.268000)
1.236000 0.000000 1.236000 ( 1.236000)
1.161000 0.000000 1.161000 ( 1.161000)
1.163000 0.000000 1.163000 ( 1.163000)
Measure string appends (via normal Ruby)
0.728000 0.000000 0.728000 ( 0.728000)
0.731000 0.000000 0.731000 ( 0.731000)
0.543000 0.000000 0.543000 ( 0.544000)
0.578000 0.000000 0.578000 ( 0.578000)
0.531000 0.000000 0.531000 ( 0.531000)
So I added another one that better tested the result of Rubifying return
values from Java. Basically, this test compares calling
System.currentTimeMillis, ideally a pretty cheap operation, with calling
String#length. Both should result in an int/long becoming a Fixnum. But
the performance difference is staggering:
Measure System.currentTimeMillis, int becoming Fixnum
7.816000 0.000000 7.816000 ( 7.816000)
8.010000 0.000000 8.010000 ( 8.011000)
8.063000 0.000000 8.063000 ( 8.064000)
7.751000 0.000000 7.751000 ( 7.750000)
8.111000 0.000000 8.111000 ( 8.111000)
Measure string.length, integer length to fixnum
0.532000 0.000000 0.532000 ( 0.533000)
0.509000 0.000000 0.509000 ( 0.509000)
0.514000 0.000000 0.514000 ( 0.512000)
0.502000 0.000000 0.502000 ( 0.502000)
0.500000 0.000000 0.500000 ( 0.500000)
Now I don't doubt that currentTimeMillis may have a bit more overhead to
it than just returning a new Fixnum based on a length field, but that
certainly doesn't seem to account for this. We're talking over a
magnitude slower!
The odd thing about this is that there should be very little challenge
in making return values quickly rubify to an appropriate type. We know
the return value from a given method isn't going to change, and we know
exactly how to box it or wrap it. So what's the deal?
- Charlie
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email