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


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

Re: One code is aggressively optimised, while another not. Why?

From Cecil Westerhof <Cecil@decebal.nl>
Newsgroups comp.lang.java.programmer
Subject Re: One code is aggressively optimised, while another not. Why?
Date 2017-07-13 09:51 +0200
Organization Decebal Computing
Message-ID <87h8yg6ag8.fsf@munus.decebal.nl> (permalink)
References <87lgnu5b9o.fsf@munus.decebal.nl> <ok58hq$s4n$1@dont-email.me>

Show all headers | View raw


Eric Sosman <esosman@comcast-dot-net.invalid> writes:

> On 7/12/2017 4:07 AM, Cecil Westerhof wrote:
>> I am looking into some performance metrics. I have the following code:
>> [... incomplete code fragments deleted; see up-thread ...]
>>
>> The second code takes about 50% more time to execute. No surprise
>> there. But the first code is aggressively optimised [...]
>>
>> Why the difference?
>
>     Perhaps someone could suggest an answer were the complete
> program made available for inspection.  Hint, hint.

I uploaded the current program to:
    https://github.com/CecilWesterhof/JavaExamples/blob/master/BoxedTest.java

Originally it was to show the risks of using autoboxing, but when
using an integer instead of a long I got this surprising result.

Only with long int I see an improvement in the performance. And quit a
big one.

The output I get on my system is:
    09:02:30: Timing long int    
    09:02:30: took 2.06E+00 seconds.
    09:02:32: took 1.21E-03 seconds.
    09:02:32: took 1.01E-04 seconds.
    09:02:32: took 7.38E-07 seconds.
    09:02:32: took 7.13E-07 seconds.

    09:02:32: Timing long long   
    09:02:32: took 3.06E+00 seconds.
    09:02:35: took 3.05E+00 seconds.
    09:02:38: took 3.79E+00 seconds.
    09:02:42: took 3.84E+00 seconds.
    09:02:46: took 3.81E+00 seconds.

    09:02:50: Timing Long int    
    09:02:50: took 3.46E+01 seconds.
    09:03:24: took 3.75E+01 seconds.
    09:04:02: took 3.62E+01 seconds.
    09:04:38: took 3.62E+01 seconds.
    09:05:14: took 3.97E+01 seconds.

    09:05:54: Timing Long long   
    09:05:54: took 3.61E+01 seconds.
    09:06:30: took 3.69E+01 seconds.
    09:07:07: took 3.65E+01 seconds.
    09:07:43: took 3.66E+01 seconds.
    09:08:20: took 3.75E+01 seconds.

    09:08:57: Timing long Integer
    09:08:57: took 2.63E+01 seconds.
    09:09:24: took 2.49E+01 seconds.
    09:09:49: took 2.57E+01 seconds.
    09:10:14: took 2.52E+01 seconds.
    09:10:40: took 2.49E+01 seconds.

    09:11:05: Timing long Long   
    09:11:05: took 3.63E+01 seconds.
    09:11:41: took 3.67E+01 seconds.
    09:12:18: took 3.41E+01 seconds.
    09:12:52: took 3.39E+01 seconds.
    09:13:26: took 3.41E+01 seconds.

    09:14:00: Timing Long Integer
    09:14:00: took 5.49E+01 seconds.
    09:14:55: took 5.47E+01 seconds.
    09:15:49: took 5.77E+01 seconds.
    09:16:47: took 5.68E+01 seconds.
    09:17:44: took 5.71E+01 seconds.

    09:18:41: Timing Long Long   
    09:18:41: took 6.68E+01 seconds.
    09:19:48: took 6.68E+01 seconds.
    09:20:54: took 6.64E+01 seconds.
    09:22:01: took 6.63E+01 seconds.
    09:23:07: took 7.30E+01 seconds.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

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


Thread

One code is aggressively optimised, while another not. Why? Cecil Westerhof <Cecil@decebal.nl> - 2017-07-12 10:07 +0200
  Re: One code is aggressively optimised, while another not. Why? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-07-12 09:38 -0400
    Re: One code is aggressively optimised, while another not. Why? Cecil Westerhof <Cecil@decebal.nl> - 2017-07-13 09:51 +0200
      Re: One code is aggressively optimised, while another not. Why? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-07-13 11:05 -0400
        Re: One code is aggressively optimised, while another not. Why? Cecil Westerhof <Cecil@decebal.nl> - 2017-07-13 18:52 +0200
          Re: One code is aggressively optimised, while another not. Why? Cecil Westerhof <Cecil@decebal.nl> - 2017-07-13 19:51 +0200
  Re: One code is aggressively optimised, while another not. Why? Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2017-07-12 09:19 -0500
    Re: One code is aggressively optimised, while another not. Why? Martin Gregorie <martin@address-in-sig.invalid> - 2017-07-12 17:04 +0000
  Re: One code is aggressively optimised, while another not. Why? Arne VajhĂžj <arne@vajhoej.dk> - 2017-07-12 21:02 -0400

csiph-web