3 ms·
As you say, it depends very much on what the code is doing. In particular, anything requiring manipulating unsigned values all over the place will be a lot slo
by TheLoneWolfling 12y ago
As you say, it depends very much on what the code is doing.
In particular, anything requiring manipulating unsigned values all over the place will be a lot slower.
Also, see this[1] for talk about JGit. An actual project with direct comparisons.
[1] http://marc.info/?l=git&m=124111702609723 http://marc.info/?l=git&m=124111702609723
- pjmlp 12y agoThose comparisons will be again out of date when Java 9+ comes out with value types, official unsafe package and lots of other goodies for performance being worked on.
- mike_hearn 12y agoI'm not aware of any intent on adding unsigned types in Java 9 though. The lack of them is a real PITA, for sure. Not only for performance but it's incredibly easy to forget a & 0xFF here or there and introduce bugs. The MMAP thing is also a good point. I believe HotSpot will compile the get methods on the MappedByteBuffer down to raw access so it shouldn't matter much for performance, in theory, but the code is still damned ugly. I never understood why they can't expose it as a byte[].
- pjmlp 12y ago> I'm not aware of any intent on adding unsigned types in Java 9 though. You kind of have them in Java 8, but not as primitive type. https://blogs.oracle.com/darcy/entry/unsigned_api https://blogs.oracle.com/darcy/entry/unsigned_api I also think a very least having ubyte would be quite nice. Apparently the reason behind the decision has to do with overflows and underflows in unsigned arithmetic. Hotspot is just one of many Java native compilers out there , so it is better not to rely on what Hotspot does. On the other hand, you can make use of JIT Watch or Solaris Studio debugging to see what Assembly is being generated. > I never understood why they can't expose it as a byte[]. Maybe the official unsafe class will make this better.