Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How much efficient is Java 6 to Java 1.3?

Reply
Thread Tools

How much efficient is Java 6 to Java 1.3?

 
 
Andreas Leitgeb
Guest
Posts: n/a
 
      04-12-2008
Roedy Green <> wrote:
> As optimisers get more and more clever it gets less an less important
> precisely how you specify your algorithm.


I wonder, if optimizers are or will (ever) be able to optimize
even this particular anti-pattern:

String s="";
for(<whateveloop>) {
s+= <something> ; <...>
}

such that only one StringBuilder is used, rather than one for
each iteration.(*)

Theoretically, it doesn't seem entirely infeasible to me.

For readers of a certain other current (sub-)thread:
(*) This would be one case, where re-using the StringBuilder
would be much more efficient after all, because it's state
at the end of each iteration is exactly what it would be
initialized to for the next one. The "t4(re-init)" would
be 0 here, quite unlike the t4(init to "s"'s content).

 
Reply With Quote
 
 
 
 
Arne Vajhøj
Guest
Posts: n/a
 
      04-13-2008
Roedy Green wrote:
> On Sat, 12 Apr 2008 14:45:21 -0400, Arne Vajhøj <>
> wrote, quoted or indirectly quoted someone who said :
>> And it is slightly faste. But we are down in the nanoseconds magnitude.

>
> StringBuilder was much faster than StringBuffer, then Sun improved the
> code for locking so the gain was reduced. Ditto for Vector and
> ArrayList.


StringBuilder was introduced in 1.5 - I think most of the
improvements in synchronization had already been done.

ArrayList was introduced in 1.2 and that was an entire different
matter.

If I were to guess then it was at least as important to
avoid the frequent mistakes caused by people who thought
using a thread safe class would make their code thread safe
than for the performance gain. But it is pure speculation.

Arne
 
Reply With Quote
 
 
 
 
Arne Vajhøj
Guest
Posts: n/a
 
      04-13-2008
Andreas Leitgeb wrote:
> I wonder, if optimizers are or will (ever) be able to optimize
> even this particular anti-pattern:
>
> String s="";
> for(<whateveloop>) {
> s+= <something> ; <...>
> }
>
> such that only one StringBuilder is used, rather than one for
> each iteration.(*)
>
> Theoretically, it doesn't seem entirely infeasible to me.


Unless there is something in the JLS or VM Spec that
prohibits this type of optimization, then it should
indeed be possible.

Arne

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      04-13-2008
On 12 Apr 2008 22:22:35 GMT, Andreas Leitgeb
<> wrote, quoted or indirectly quoted
someone who said :

>
>I wonder, if optimizers are or will (ever) be able to optimize
>even this particular anti-pattern:


see http://mindprod.com/project/stringbuilderoptimiser.html
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      04-13-2008
On Sat, 12 Apr 2008 20:56:41 -0400, Lew <> wrote,
quoted or indirectly quoted someone who said :

>However, the reasons to use ArrayList in preference to Vector are not related
>to performance.


What are they?
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
Andreas Leitgeb
Guest
Posts: n/a
 
      04-13-2008
Roedy Green <> wrote:
><> wrote:
>>I wonder, if optimizers are or will (ever) be able to optimize
>>even this particular anti-pattern:

> see http://mindprod.com/project/stringbuilderoptimiser.html


"Estimated Existing Implementations": 0

PS:
That reminds me of another of your project-suggestions, namely
http://mindprod.com/project/interfacefinder.html
Some time ago, I asked you to change the text from
"Split it at the semicolons"
to
"Split it at occurrances of File.pathSeparator"

But you didn't show any reaction at all, not even one like "I'm a
Windows guy, and don't care about teaching portability", so I'm not
sure you even read my previous bug-reports. I hope, you see it this
time.

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      04-14-2008
On 13 Apr 2008 09:47:54 GMT, Andreas Leitgeb
<> wrote, quoted or indirectly quoted
someone who said :

>
>But you didn't show any reaction at all, not even one like "I'm a
>Windows guy, and don't care about teaching portability", so I'm not
>sure you even read my previous bug-reports. I


I don't read all the messages in the newsgroups, and even the ones I
do read I mostly skim, so it won't necessarily register you are asking
for a change to the text on one of my web pages. If you want to make
sure I notice, email me. see http://mindprod.com/contact/contact.html

Subject: Error on http://mindprod.com/project/interfacefinder.html

will help me notice even if the spam filter misfiles.

I tried several times to get Linux to co-exist with Windows , but all
it does it trash my partition tables requiring a from scratch
reinstall of everything. That is inexcusable. I want Windows to fade
into the sunset, but if Linunoids are going to make installs so
difficult, that can't happen. The initial install has to be
idiot-proof.

Those essays at http://mindprod.com/project/projects.html are just
project suggestions, to give you then general idea of what you might
do for a project, not specifications. Your beef should primarily be
with someone who implemented them in an unnecessarily
platform-specific way.

Any any rate, your correction will be in there within the hour.

--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      04-14-2008
On Sun, 13 Apr 2008 08:48:17 -0400, Lew <> wrote,
quoted or indirectly quoted someone who said :

> That's only one hop longer than a direct load of the
>character. Part of the student project (excellent service to the community to
>post those projects, btw) should be to benchmark the difference between the
>String- and character-argument calls before implementing the optimization, and
>to compare any change in the String-argument call times to that difference as
>well.


When you are writing general purpose optimisers you go for broke. You
shave every nanosecond you can. It may matter to someone, even if
just an artificial benchmark against the competition.

For a given application, of course, you measure and don't bother with
negligible optimisations.


To an assembler programmer such as myself append(' ') is obviously
vastly faster than append (" "). Because it is a trivial
optimisation, so you might as well do it.

append( ' ' )
might be optimised roughly like this:

if ( ++bufflen >= bufflimt ) { handleOverflow() };
buff[ bufflen ] = ' ';


append( " ")
will be roughly implemented like this:

int end = bufflen + literalxxx.length();
if (end >= bufflimt ) { handleOverflow() };
for ( int i = 0; i< literalxxx.length(); i++ )
{
buff[ bufflen + i ] = literalxxx[ i ];
}
bufflen = end;


--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      04-14-2008
On Sat, 12 Apr 2008 23:05:28 -0400, Lew <> wrote,
quoted or indirectly quoted someone who said :

>To me, one reason is Occam's Razor, loosely speaking.


I have added this to the entry on "ArrayList" at
http://mindprod.com/jgloss/arraylist.html to summarise your objections
to Vector.

"Don't use Vector in new code. It has confusing redundant methods,
and the synchronisation is excessive and implicit."
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
Andreas Leitgeb
Guest
Posts: n/a
 
      04-14-2008
Roedy Green <> wrote:
> On 13 Apr 2008 09:47:54 GMT, Andreas Leitgeb wrote:
>>But you didn't show any reaction at all, ...

> I don't read all the messages in the newsgroups, and even the ones I
> do read I mostly skim, so it won't necessarily register you are asking
> for a change to the text on one of my web pages. If you want to make
> sure I notice, email me. see http://mindprod.com/contact/contact.html
> Subject: Error on http://mindprod.com/project/interfacefinder.html


I did email you, but quite likely with a different one than what you
suggested here.

> will help me notice even if the spam filter misfiles.


That might have happened.

> I tried several times to get Linux to co-exist with Windows,


This is of course not a forum to discuss windows+linux
co-installation, and I'm not even able to help much anyway,
since my machines are linux only since roughly a decade.

I casually read remarks by others who complained that the
installation procedures that worked with some version of
windows suddenly stopped working with some newer version
of windows, so this gives me some idea of the culprit.

> Those essays at http://mindprod.com/project/projects.html are just
> project suggestions, to give you then general idea of what you might
> do for a project, not specifications. Your beef should primarily be
> with someone who implemented them in an unnecessarily
> platform-specific way.

Generally, you're right, unless the platform-lock is already
(inadvertedly) suggested in the outset.

> Any any rate, your correction will be in there within the hour.


It's better now, but I think it would be best to principially
suggest File.pathSeperator, pointing out that this way should
be the preferred one over any hardcoding of platform-specific
values. As it is now, it sounds like: only if you're really
really sure that you need it to run on more platforms, use
the pathSeparator...

Your students'-projects surely have some teaching effect from
their very outset, so let's not teach the wrong message.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
DVD Soon or much much later? anthony DVD Video 10 07-08-2005 07:13 PM
Simulation questions...how much is too much? =?Utf-8?B?VGlwcHk=?= Microsoft Certification 0 04-16-2005 04:47 AM
CPU Heat--how much is too much? PowerPost2000 Computer Support 4 12-22-2003 12:40 AM
paranoia... much too much adcl Computer Support 14 11-08-2003 05:18 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57