Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #35665

Re: Java is faster!

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Java is faster!
Date 2016-09-28 15:14 -0400
Organization A noiseless patient Spider
Message-ID <nsh4q2$fdv$1@dont-email.me> (permalink)
References (2 earlier) <ns93lq$fpv$1@news.albasani.net> <ns95v0$m1h$1@dont-email.me> <nsc2qk$uip$1@news.albasani.net> <nse11l$e82$1@dont-email.me> <nsh1l8$cl7$1@news.albasani.net>

Show all headers | View raw


On 9/28/2016 2:20 PM, Sebastian wrote:
> Am 27.09.2016 um 20:21 schrieb Eric Sosman:
>> On 9/26/2016 5:09 PM, j4n bur53 wrote:
>>> Yes and Yes.
>>> [The second "Yes" answering my question about how he measured
>>> the cost of casting.]
>>
>>     If your results are not proprietary trade secrets or something,
>> could you disclose them?  We all realize that different machines/JVM's
>> will produce different timings for identical classes, but even some
>> not-completely-reliable "indicative" numbers would be of considerable
>> interest to me, and, I imagine, to others as well.
>>
> Well, Marko Topolnik has already taken the trouble, see here:
> http://stackoverflow.com/a/17764556
>
> tl;dr: there is no noticeable cost to casting

     Three observations:

     First, cheap casts would appear to be a prerequisite for a usable
JVM.  Applying a cast to a reference should be approximately as hard
as discovering the class of the referenced object, and Java does this
a LOT.  Every call to a possibly-overridden method, for example, needs
to discover which class provides the method's code.  If casts were slow,
the "approximately equivalent effort" of method dispatch would also be
slow, and Java itself would be slow.  (Or "slowER," for you doubters.)

     Second, Jan Burse has reported elsethread that casts have caused
performance problems for him: "[...] bumpted my head speed wise just
because of the many casts I needed."  I find this surprising, and am
interested in learning more about his results (if he's at liberty to
share them).  Although the First point "stands to reason," actual
data trumps "stands to reason" any day.

     Third, Marko Topolnik's benchmark doesn't seem terribly convincing
to me (even though it supports First).  It may in fact be correct, but
there's a lot more going on than the cast vs. no-cast comparison, and
I'm worried that the difference he's trying to measure may have been
lost in the noise.  For example, note that the testNoDowncast() method
does in fact perform at least ten thousand downcasts. testDowncast()
performs twenty thousand, but comparing 2N to N instead of N to 0 is
at the very least an eyebrow-raiser.  (In Topolnik's defense, he's
trying to answer a slightly more specific question than the one we're
wondering about.)

     So, I hope Jan can show his results.

-- 
esosman@comcast-dot-net.invalid
The Tooth Fairy has gone high-tech, now pays in Bitecoin.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Java is faster! Roedy Green <inquiry@mindprod.com> - 2016-09-25 03:28 -0700
  Re: Java is faster! j4n bur53 <janburse@fastmail.fm> - 2016-09-25 20:05 +0200
    Re: Java is faster! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-09-25 14:44 -0400
      Re: Java is faster! j4n bur53 <janburse@fastmail.fm> - 2016-09-26 23:09 +0200
        Re: Java is faster! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-09-27 10:51 -0400
          Re: Java is faster! Sebastian <nowhere@nirvana.org> - 2016-09-28 23:50 +0530
            Re: Java is faster! Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-09-28 15:14 -0400
              Re: Java is faster! j4n bur53 <janburse@fastmail.fm> - 2016-09-29 09:11 +0200
    Re: Java is faster! Arne Vajhøj <arne@vajhoej.dk> - 2016-09-29 21:24 -0400
  Re: Java is faster! Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-25 16:37 -0400
    Re: Java is faster! Eric Douglas <e.d.programmer@gmail.com> - 2016-09-26 05:47 -0700
      Re: Java is faster! Robert Klemme <shortcutter@googlemail.com> - 2016-10-04 23:04 +0200
  Re: Java is faster! Arne Vajhøj <arne@vajhoej.dk> - 2016-09-29 21:18 -0400

csiph-web