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


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

Re: execution speed when printing

Path csiph.com!aioe.org!.POSTED!not-for-mail
From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: execution speed when printing
Date Mon, 13 Feb 2017 20:32:16 -0500
Organization Aioe.org NNTP Server
Lines 34
Message-ID <o7tmmt$mch$1@gioia.aioe.org> (permalink)
References <speed-20170214014104@ram.dialup.fu-berlin.de>
NNTP-Posting-Host PBuS014lhzVyHjLbXmo/ZQ.user.gioia.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 8bit
X-Complaints-To abuse@aioe.org
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1
X-Notice Filtered by postfilter v. 0.8.2
Xref csiph.com comp.lang.java.programmer:36257

Show key headers only | View raw


On 2/13/2017 7:48 PM, Stefan Ram wrote:
>   I believe that (assuming »d« has type »double«)
>
> java.lang.System.out.print( d );
> java.lang.System.out.println( " miles" );
>
>   might be faster than
>
> java.lang.System.out.println( d +" miles" );
>
>   . Do you think that on most implementations it will really
>   be faster? (Yes, I know. But would I write a post, if I had
>   time to write a microbenchmark? Moreover, a part of the cost
>   of the »+« might escape a microbenchmark, when it occurs in
>   a GC run that happens only much later but might increase the
>   overall runtime of a program.)
>
>   Ok, printing to a console always is very slow, but the
>   output might be redirected to a file, and it might serve
>   as a model for similar situations that do not involve I/O.
>
>   If it is faster, should it be mentioned in a course for
>   beginners?

I think it would be a disaster to get beginners focused on
that sort of premature optimization.

Regarding the issue itself then it is not obvious to me that the
concatenation is more expensive than the extra calls.

Arne


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


Thread

Re: execution speed when printing Arne Vajhøj <arne@vajhoej.dk> - 2017-02-13 20:32 -0500
  Re: execution speed when printing Eric Douglas <e.d.programmer@gmail.com> - 2017-02-14 07:47 -0800

csiph-web