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


Groups > comp.lang.java.programmer > #22526 > unrolled thread

simple StringBuilder proposal

Started byRoedy Green <see_website@mindprod.com.invalid>
First post2013-02-26 03:53 -0800
Last post2013-03-27 10:17 +0100
Articles 13 on this page of 53 — 15 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  simple StringBuilder proposal Roedy Green <see_website@mindprod.com.invalid> - 2013-02-26 03:53 -0800
    Re: simple StringBuilder proposal Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-02-26 15:15 +0000
      Re: simple StringBuilder proposal Roedy Green <see_website@mindprod.com.invalid> - 2013-02-27 10:25 -0800
      Re: simple StringBuilder proposal Roedy Green <see_website@mindprod.com.invalid> - 2013-02-27 10:30 -0800
        Re: simple StringBuilder proposal Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-02-28 08:30 +0000
          Re: simple StringBuilder proposal markspace <markspace@nospam.nospam> - 2013-02-28 07:54 -0800
    Re: simple StringBuilder proposal markspace <markspace@nospam.nospam> - 2013-02-26 08:31 -0800
      Re: simple StringBuilder proposal Lew <lewbloch@gmail.com> - 2013-02-26 10:33 -0800
        Re: simple StringBuilder proposal markspace <markspace@nospam.nospam> - 2013-02-26 10:47 -0800
          Re: simple StringBuilder proposal Leif Roar Moldskred <leifm@dimnakorr.com> - 2013-02-26 13:29 -0600
            Re: simple StringBuilder proposal Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2013-02-26 12:08 -0800
          Re: simple StringBuilder proposal Lew <lewbloch@gmail.com> - 2013-02-26 13:32 -0800
            Re: simple StringBuilder proposal Roedy Green <see_website@mindprod.com.invalid> - 2013-02-27 10:33 -0800
          Re: simple StringBuilder proposal Robert Klemme <shortcutter@googlemail.com> - 2013-02-26 22:53 +0100
            Re: simple StringBuilder proposal markspace <markspace@nospam.nospam> - 2013-02-26 15:54 -0800
              Re: simple StringBuilder proposal Robert Klemme <shortcutter@googlemail.com> - 2013-03-01 07:35 +0100
        Re: simple StringBuilder proposal Roedy Green <see_website@mindprod.com.invalid> - 2013-02-27 10:31 -0800
          Re: simple StringBuilder proposal Sven Köhler <remove-sven.koehler@gmail.com> - 2013-02-28 05:14 +0100
    Re: simple StringBuilder proposal Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-02-26 09:41 -0800
    Re: simple StringBuilder proposal Jan Burse <janburse@fastmail.fm> - 2013-02-26 20:21 +0100
      Re: simple StringBuilder proposal Joerg Meier <joergmmeier@arcor.de> - 2013-02-26 23:07 +0100
        Re: simple StringBuilder proposal Jan Burse <janburse@fastmail.fm> - 2013-02-27 00:09 +0100
          Re: simple StringBuilder proposal Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-02-26 15:19 -0800
            Re: simple StringBuilder proposal Jim Janney <jjanney@shell.xmission.com> - 2013-02-27 09:34 -0700
              Re: simple StringBuilder proposal Jan Burse <janburse@fastmail.fm> - 2013-02-27 19:18 +0100
                Re: simple StringBuilder proposal Arne Vajhøj <arne@vajhoej.dk> - 2013-02-27 19:56 -0500
                  Re: simple StringBuilder proposal Jan Burse <janburse@fastmail.fm> - 2013-02-28 10:19 +0100
                    Re: simple StringBuilder proposal Arne Vajhøj <arne@vajhoej.dk> - 2013-02-28 08:16 -0500
                      Re: simple StringBuilder proposal Jim Janney <jjanney@shell.xmission.com> - 2013-02-28 16:40 -0700
                        Re: simple StringBuilder proposal Arne Vajhøj <arne@vajhoej.dk> - 2013-02-28 18:51 -0500
              Re: simple StringBuilder proposal Arne Vajhøj <arne@vajhoej.dk> - 2013-02-27 20:01 -0500
    Re: simple StringBuilder proposal Silvio <silvio@internet.com> - 2013-02-26 22:03 +0100
      Re: simple StringBuilder proposal Silvio <silvio@internet.com> - 2013-02-26 22:04 +0100
    Re: simple StringBuilder proposal Sven Köhler <remove-sven.koehler@gmail.com> - 2013-02-27 03:47 +0100
      FastCat 'performance' (was: simple StringBuilder proposal) Joerg Meier <joergmmeier@arcor.de> - 2013-02-27 18:16 +0100
        Re: FastCat 'performance' markspace <markspace@nospam.nospam> - 2013-02-27 09:58 -0800
          Re: FastCat 'performance' Jan Burse <janburse@fastmail.fm> - 2013-02-27 19:31 +0100
            Re: FastCat 'performance' Joerg Meier <joergmmeier@arcor.de> - 2013-02-27 20:00 +0100
              Re: FastCat 'performance' Jan Burse <janburse@fastmail.fm> - 2013-02-27 20:41 +0100
                Re: FastCat 'performance' Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-02-27 12:38 -0800
                  Re: FastCat 'performance' Joerg Meier <joergmmeier@arcor.de> - 2013-02-27 21:58 +0100
                    Re: FastCat 'performance' Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-02-27 13:32 -0800
                  Re: FastCat 'performance' Lew <lewbloch@gmail.com> - 2013-02-27 13:42 -0800
                    Re: FastCat 'performance' Lew <lewbloch@gmail.com> - 2013-02-27 13:44 -0800
                    Re: FastCat 'performance' Joerg Meier <joergmmeier@arcor.de> - 2013-02-27 22:51 +0100
                      Re: FastCat 'performance' Sven Köhler <remove-sven.koehler@gmail.com> - 2013-02-28 05:19 +0100
                        Re: FastCat 'performance' Joerg Meier <joergmmeier@arcor.de> - 2013-02-28 13:09 +0100
                  Re: FastCat 'performance' markspace <markspace@nospam.nospam> - 2013-02-27 13:57 -0800
                    Re: FastCat 'performance' Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-02-27 15:23 -0800
                  Re: FastCat 'performance' Arne Vajhøj <arne@vajhoej.dk> - 2013-02-27 18:52 -0500
                  Re: FastCat 'performance' Sven Köhler <remove-sven.koehler@gmail.com> - 2013-03-01 17:26 +0100
        Re: FastCat 'performance' Sven Köhler <remove-sven.koehler@gmail.com> - 2013-02-27 21:00 +0100
        Re: FastCat 'performance' (was: simple StringBuilder proposal) Wanja Gayk <brixomatic@yahoo.com> - 2013-03-27 10:17 +0100

Page 3 of 3 — ← Prev page 1 2 [3]


#22595 — Re: FastCat 'performance'

FromJoerg Meier <joergmmeier@arcor.de>
Date2013-02-27 21:58 +0100
SubjectRe: FastCat 'performance'
Message-ID<32h92bxkny4k$.16dj0eh04iqld$.dlg@40tude.net>
In reply to#22592
On Wed, 27 Feb 2013 12:38:11 -0800, Daniel Pitts wrote:

> I've made the Strings you append longer, and I've fixed the estimates 
> for the FastCat and the StringBu*ers constructors to be spot-on:

> Fresh SB/FCs:
> Cat> Init: 00.000ms, Loop: 00.175ms, End: 00.000ms, Total: 00.175ms.
> Buf> Init: 00.000ms, Loop: 00.227ms, End: 00.000ms, Total: 00.227ms.
> Bui> Init: 00.000ms, Loop: 00.236ms, End: 00.000ms, Total: 00.236ms.
> Reused SB/FCs:
> Cat> Init: 00.000ms, Loop: 00.023ms, End: 00.375ms, Total: 00.398ms.
> Buf> Init: 00.101ms, Loop: 00.048ms, End: 00.130ms, Total: 00.279ms.
> Bui> Init: 00.092ms, Loop: 00.052ms, End: 00.130ms, Total: 00.274ms.

I'm curious, would you mind sharing the updated code on a pastebin
somewhere ? Writing benchmarks is always tricky, so I'd be happy to learn
from your changes.

Liebe Gruesse,
		Joerg

-- 
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.

[toc] | [prev] | [next] | [standalone]


#22596 — Re: FastCat 'performance'

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2013-02-27 13:32 -0800
SubjectRe: FastCat 'performance'
Message-ID<EXuXs.78383$KR.72352@newsfe27.iad>
In reply to#22595
On 2/27/13 12:58 PM, Joerg Meier wrote:
> On Wed, 27 Feb 2013 12:38:11 -0800, Daniel Pitts wrote:
>
>> I've made the Strings you append longer, and I've fixed the estimates
>> for the FastCat and the StringBu*ers constructors to be spot-on:
>
>> Fresh SB/FCs:
>> Cat> Init: 00.000ms, Loop: 00.175ms, End: 00.000ms, Total: 00.175ms.
>> Buf> Init: 00.000ms, Loop: 00.227ms, End: 00.000ms, Total: 00.227ms.
>> Bui> Init: 00.000ms, Loop: 00.236ms, End: 00.000ms, Total: 00.236ms.
>> Reused SB/FCs:
>> Cat> Init: 00.000ms, Loop: 00.023ms, End: 00.375ms, Total: 00.398ms.
>> Buf> Init: 00.101ms, Loop: 00.048ms, End: 00.130ms, Total: 00.279ms.
>> Bui> Init: 00.092ms, Loop: 00.052ms, End: 00.130ms, Total: 00.274ms.
>
> I'm curious, would you mind sharing the updated code on a pastebin
> somewhere ? Writing benchmarks is always tricky, so I'd be happy to learn
> from your changes.
>
> Liebe Gruesse,
> 		Joerg
>

Here it is in all its glory:

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.mindprod.fastcat.FastCat;


class CatTester {
     public static final String LONG_STRING = 
"abcdefgabcdefgabcdefgabcdefgabc" +
             "defgabcdefgabcdefgabcdefgabcdefgabcde" +
             "defgabcdefgabcdefgabcdefgabcdefgabcde" +
             "defgabcdefgabcdefgabcdefgabcdefgabcde" +
             "defgabcdefgabcdefgabcdefgabcdefgabcde" +
             "defgabcdefgabcdefgabcdefgabcdefgabcde" +
             "defgabcdefgabcdefgabcdefgabcdefgabcde" +
             "defgabcdefgabcdefgabcdefgabcdefgabcde" +
             "defgabcdefgabcdefgabcdefgabcdefgabcde" +
             "fg"
             ;
     public static final String ANOTHER_STRING = "xvck" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "blahblahblahblahxjcvh" +
             "";

     private interface Tester {
		public void init();
		public int test(final long junk);
         String conclude();
     }

	private static class TestFastCat implements Tester {
		protected FastCat sb;

		public TestFastCat() {
		}

         public void init() {
         }

         public String conclude() {
             if (sb != null) {
                 return sb.toString();
             }
             return null;
         }


		public int test(final long junk) {
			final FastCat sbLocal = sb == null ? new FastCat(6) : sb;
			final int start = sbLocal.length();
             sbLocal.append(LONG_STRING);
             sbLocal.append(1234);
             sbLocal.append(ANOTHER_STRING);
             sbLocal.append(junk);
             sbLocal.append(ANOTHER_STRING);
             sbLocal.append(junk + 1);
             if (sbLocal != sb) {
                 sbLocal.toString();
             }
			return sbLocal.length() - start;
		}
	}

	private static class TestStringBuffer implements Tester {
		protected StringBuffer	sb;

		public TestStringBuffer() {
		}

         public void init() {
         }

         public int test(final long junk) {
			final StringBuffer sbLocal = sb == null ? new StringBuffer() : sb;
			final int start = sbLocal.length();
			sbLocal.append(LONG_STRING);
			sbLocal.append(1234);
			sbLocal.append(ANOTHER_STRING);
			sbLocal.append(junk);
			sbLocal.append(ANOTHER_STRING);
			sbLocal.append(junk + 1);
             if (sbLocal != sb) {
                 sbLocal.toString();
             }
			return sbLocal.length() - start;
		}

         public String conclude() {
             if (sb != null) {
                 return sb.toString();
             }
             return null;
         }

	}

	private static class TestStringBuilder implements Tester {
         protected StringBuilder	sb;

		public TestStringBuilder() {
		}


         public void init() {
         }

         public int test(final long junk) {
			final StringBuilder sbLocal = sb == null ? new StringBuilder() : sb;
			final int start = sbLocal.length();
			sbLocal.append(LONG_STRING);
			sbLocal.append(1234);
			sbLocal.append(ANOTHER_STRING);
			sbLocal.append(junk);
			sbLocal.append(ANOTHER_STRING);
			sbLocal.append(junk + 1);
             if (sbLocal != sb) {
                 sbLocal.toString();
             }
			return sbLocal.length() - start;
		}

         public String conclude() {
             if (sb != null) {
                 return sb.toString();
             }
             return null;
         }

	}

	public static void main(final String[] args) {
		new CatTester().test();
	}

	private final DateFormat	DF	= new SimpleDateFormat("ss'.'SSS'ms'");

	private long loopTest(final String name, final Tester tester, final int 
loops) {
         final long start = System.currentTimeMillis();
         tester.init();
         final long initTime = System.currentTimeMillis();
         long junk = 0;
         for (int i = 1; i < loops; i++) {
             junk += tester.test(junk);
         }
         final long appendTime = System.currentTimeMillis();
         tester.conclude();
         if (name != null) {
             System.out.println(String.format("%s> Init: %s, Loop: %s, 
End: %s, Total: %s.",
                     name,
                     timestamp(start, initTime),
                     timestamp(initTime, appendTime),
                     timestamp(appendTime),
                     timestamp(start))
                     );
		}
         return junk;
	}

	private void test() {
	    final int loops = 100000;

		// To warm up the VM, HotSpot etc
         loopTest(null, new TestFastCat(), loops);
         final long length = loopTest(null, new TestStringBuilder(), 
loops) / 10;
         loopTest(null, new TestStringBuffer(), loops);
         loopTest(null, new TestFastCatReuse(loops), loops);
         loopTest(null, new TestStringBufferReuse(length), loops);
         loopTest(null, new TestStringBuilderReuse(length), loops);
         for (int i = 0; i < 3; ++i) {
             System.out.println("Fresh SB/FCs:");
             loopTest("Cat", new TestFastCat(), loops);
             loopTest("Buf", new TestStringBuffer(), loops);
             loopTest("Bui", new TestStringBuilder(), loops);

             System.out.println("Reused SB/FCs:");
             loopTest("Cat", new TestFastCatReuse(loops), loops);
             loopTest("Buf", new TestStringBufferReuse(length), loops);
             loopTest("Bui", new TestStringBuilderReuse(length), loops);
         }
	}

     private String timestamp(final long start) {
         return timestamp(start, System.currentTimeMillis());
     }

     private String timestamp(final long start, long endTime) {
		return DF.format(new Date(endTime - start));
	}

     private static class TestFastCatReuse extends TestFastCat {
         private final int loops;

         public TestFastCatReuse(int loops) {
             this.loops = loops;
         }

         public void init() { sb = new FastCat(loops * 6); }
     }

     private static class TestStringBufferReuse extends TestStringBuffer {
         private final long length;

         public TestStringBufferReuse(long length) {
             this.length = length;
         }

         public void init() { sb = new StringBuffer((int) length);}
     }

     private static class TestStringBuilderReuse extends TestStringBuilder {
         private final long length;

         public TestStringBuilderReuse(long length) {
             this.length = length;
         }

         public void init() { sb = new StringBuilder((int) length); }
     }
}

[toc] | [prev] | [next] | [standalone]


#22597 — Re: FastCat 'performance'

FromLew <lewbloch@gmail.com>
Date2013-02-27 13:42 -0800
SubjectRe: FastCat 'performance'
Message-ID<89669b41-7a35-434e-90cd-57f7342ee70b@googlegroups.com>
In reply to#22592
Daniel Pitts wrote:
> Jan Burse wrote:
> > Joerg Meier schrieb:
>>> So, FastCat is doing even worse if .toString() is used. And much, much
>>> worse if .toString() is used more than once.
>>>
> 
>> Ok, so then. Thanks.
> 
> Now, to be fair to Roedy, you aren't exactly using it "as proscribed", 
> and you aren't testing the time spent in the constructors.
> 
> I've made the Strings you append longer, and I've fixed the estimates 
> for the FastCat and the StringBu*ers constructors to be spot-on:
> 
> Fresh SB/FCs:
> Cat> Init: 00.000ms, Loop: 00.175ms, End: 00.000ms, Total: 00.175ms.
> Buf> Init: 00.000ms, Loop: 00.227ms, End: 00.000ms, Total: 00.227ms.
> Bui> Init: 00.000ms, Loop: 00.236ms, End: 00.000ms, Total: 00.236ms.
> Reused SB/FCs:
> 
> Cat> Init: 00.000ms, Loop: 00.023ms, End: 00.375ms, Total: 00.398ms.
> Buf> Init: 00.101ms, Loop: 00.048ms, End: 00.130ms, Total: 00.279ms.
> Bui> Init: 00.092ms, Loop: 00.052ms, End: 00.130ms, Total: 00.274ms.
> 
> For Fresh, Init/End do nothing, but toString() is called every loop.
> 
> For Reused, Init creates the buffer/builder/fastcat,  and End is the 
> single call to toString().
> 
> If I remove the estimate entirely from StringBu*er constructors, FastCat 
> does indeed win out. FastCat relies on a "good estimate" to start with, 
> so I left that estimate in.
> 
> Fresh SB/FCs:
> Cat> Init: 00.000ms, Loop: 00.187ms, End: 00.000ms, Total: 00.187ms.
> Buf> Init: 00.000ms, Loop: 00.240ms, End: 00.000ms, Total: 00.240ms.
> Bui> Init: 00.000ms, Loop: 00.236ms, End: 00.000ms, Total: 00.236ms.
> 
> Reused SB/FCs:
> Cat> Init: 00.000ms, Loop: 00.020ms, End: 00.377ms, Total: 00.397ms.
> Buf> Init: 00.000ms, Loop: 00.495ms, End: 00.122ms, Total: 00.617ms.
> Bui> Init: 00.000ms, Loop: 00.468ms, End: 00.121ms, Total: 00.589ms.
> 
> So, depending on its use, FastCat *can* be about twice as fast as 
> StringBuffer/StringBuilder.  It can, however, be significantly slower as 
> you have shown.

How does it compare to using String +?

How does it change after a 10,000-loop warmup to kick in HotSpot?

> Sorry Roedy, I'm not going to switch to FastCat any time soon.  It's not 
> a bad idea for a specialized use-case, but as a general use-case not as 
> good.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#22598 — Re: FastCat 'performance'

FromLew <lewbloch@gmail.com>
Date2013-02-27 13:44 -0800
SubjectRe: FastCat 'performance'
Message-ID<72ffa06f-8d56-42ea-bae1-b924c24b2b01@googlegroups.com>
In reply to#22597
On Wednesday, February 27, 2013 1:42:00 PM UTC-8, Lew wrote:
> Daniel Pitts wrote:
... his benchmark discussed ...

> How does it compare to using String +?
> 
> How does it change after a 10,000-loop warmup to kick in HotSpot?

I see from your followup post that you handled the warmup.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#22599 — Re: FastCat 'performance'

FromJoerg Meier <joergmmeier@arcor.de>
Date2013-02-27 22:51 +0100
SubjectRe: FastCat 'performance'
Message-ID<1h6w3eeq8kfys$.kfwnlzg0axst.dlg@40tude.net>
In reply to#22597
On Wed, 27 Feb 2013 13:42:00 -0800 (PST), Lew wrote:

> How does it compare to using String +?

I didn't include + in my initial benchmark because I learned some time ago
that both javac as well as HotSpot will just convert it to StringBuilder
behind the scenes in most circumstances.

Liebe Gruesse,
		Joerg

-- 
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.

[toc] | [prev] | [next] | [standalone]


#22608 — Re: FastCat 'performance'

FromSven Köhler <remove-sven.koehler@gmail.com>
Date2013-02-28 05:19 +0100
SubjectRe: FastCat 'performance'
Message-ID<ap843qFig73U1@mid.dfncis.de>
In reply to#22599
Am 27.02.2013 22:51, schrieb Joerg Meier:
> On Wed, 27 Feb 2013 13:42:00 -0800 (PST), Lew wrote:
> 
>> How does it compare to using String +?
> 
> I didn't include + in my initial benchmark because I learned some time ago
> that both javac as well as HotSpot will just convert it to StringBuilder
> behind the scenes in most circumstances.

Java Compilers will substitute any + operations on String with calls to
StringBuffer (-source 1.3 and below) or StringBuilder (-source 1.4 or
above). I'm not aware, of any optimizations within the JVM (e.g.
Hotspot), but at byte-code level there is no such thing as a + operator
for strings.


Regards,
  Sven

[toc] | [prev] | [next] | [standalone]


#22614 — Re: FastCat 'performance'

FromJoerg Meier <joergmmeier@arcor.de>
Date2013-02-28 13:09 +0100
SubjectRe: FastCat 'performance'
Message-ID<6k1snl8p93y1$.1kdlpb648nfoq.dlg@40tude.net>
In reply to#22608
On Thu, 28 Feb 2013 05:19:46 +0100, Sven Köhler wrote:

> Am 27.02.2013 22:51, schrieb Joerg Meier:
>> On Wed, 27 Feb 2013 13:42:00 -0800 (PST), Lew wrote:
>>> How does it compare to using String +?
>> I didn't include + in my initial benchmark because I learned some time ago
>> that both javac as well as HotSpot will just convert it to StringBuilder
>> behind the scenes in most circumstances.
> Java Compilers will substitute any + operations on String with calls to
> StringBuffer (-source 1.3 and below) or StringBuilder (-source 1.4 or
> above). I'm not aware, of any optimizations within the JVM (e.g.
> Hotspot), but at byte-code level there is no such thing as a + operator
> for strings.

I didn't want to lean too far out the window and say "in every situation"
because I was unsure and comments like that just invite someone to post
some weird technicality where one is wrong ;)

Liebe Gruesse,
		Joerg

-- 
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.

[toc] | [prev] | [next] | [standalone]


#22600 — Re: FastCat 'performance'

Frommarkspace <markspace@nospam.nospam>
Date2013-02-27 13:57 -0800
SubjectRe: FastCat 'performance'
Message-ID<kglvf0$8r2$1@dont-email.me>
In reply to#22592
On 2/27/2013 12:38 PM, Daniel Pitts wrote:
> Now, to be fair to Roedy, you aren't exactly using it "as proscribed",

<pedantic>

proscribed = forbidden
prescribed = recommended

I think you meant the latter.

</pedantic>


[toc] | [prev] | [next] | [standalone]


#22602 — Re: FastCat 'performance'

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2013-02-27 15:23 -0800
SubjectRe: FastCat 'performance'
Message-ID<FzwXs.84251$532.50104@newsfe03.iad>
In reply to#22600
On 2/27/13 1:57 PM, markspace wrote:
> On 2/27/2013 12:38 PM, Daniel Pitts wrote:
>> Now, to be fair to Roedy, you aren't exactly using it "as proscribed",
>
> <pedantic>
>
> proscribed = forbidden
> prescribed = recommended
>
> I think you meant the latter.
>
> </pedantic>
I learn something new everyday.
Indeed.  I actually meant "as intended".

[toc] | [prev] | [next] | [standalone]


#22603 — Re: FastCat 'performance'

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-02-27 18:52 -0500
SubjectRe: FastCat 'performance'
Message-ID<512e9c3e$0$286$14726298@news.sunsite.dk>
In reply to#22592
On 2/27/2013 3:38 PM, Daniel Pitts wrote:
> Sorry Roedy, I'm not going to switch to FastCat any time soon.  It's not
> a bad idea for a specialized use-case, but as a general use-case not as
> good.

It is very rarely a good idea to replace well tested builtin solutions
with some hacked code that is supposedly faster. Often it is not faster
at all. And if it is then it is often only for special cases. And if
it is more than that there are  often problems with correctness.

It can be good fun for students to play around with. But I think the
keyword here is "play".

26 years ago I spent an awful lot of time trying to optimize
Sieve of E in VAX assembler.

Arne

[toc] | [prev] | [next] | [standalone]


#22653 — Re: FastCat 'performance'

FromSven Köhler <remove-sven.koehler@gmail.com>
Date2013-03-01 17:26 +0100
SubjectRe: FastCat 'performance'
Message-ID<apc351Ff4olU1@mid.dfncis.de>
In reply to#22592
Am 27.02.2013 21:38, schrieb Daniel Pitts:
> Now, to be fair to Roedy, you aren't exactly using it "as proscribed",
> and you aren't testing the time spent in the constructors.
> 
> I've made the Strings you append longer, and I've fixed the estimates
> for the FastCat and the StringBu*ers constructors to be spot-on:

Well, in the example Roedy posted here, the strings weren't very long
either.

> So, depending on its use, FastCat *can* be about twice as fast as
> StringBuffer/StringBuilder.

Which is to be expected as a factor of two is the price to pay or
exponential growth.


Regards,
  Sven

[toc] | [prev] | [next] | [standalone]


#22588 — Re: FastCat 'performance'

FromSven Köhler <remove-sven.koehler@gmail.com>
Date2013-02-27 21:00 +0100
SubjectRe: FastCat 'performance'
Message-ID<ap76u5Fch8nU1@mid.dfncis.de>
In reply to#22578
Hi Joerg,

Am 27.02.2013 18:16, schrieb Joerg Meier:
> Because his incessant advertising irritates me, I spent a few minutes
> writing a small benchmark, comparing the performance of StringBuilder,
> StringBuffer and FastCat. The results were ... well, pretty much what one
> would expect:
> 
> Took 00:08.845ms to append 454,895,082 chars total with FastCat.
> Took 00:03.939ms to append 454,895,082 chars total with StringBuffer.
> Took 00:03.462ms to append 454,895,082 chars total with StringBuilder.

Thanks for that!


Regards,
  Sven

[toc] | [prev] | [next] | [standalone]


#23134 — Re: FastCat 'performance' (was: simple StringBuilder proposal)

FromWanja Gayk <brixomatic@yahoo.com>
Date2013-03-27 10:17 +0100
SubjectRe: FastCat 'performance' (was: simple StringBuilder proposal)
Message-ID<MPG.2bbcd76d9cb1391d989745@202.177.16.121>
In reply to#22578
In article <voqpdc2ltdvq$.yl7an5lgvzea.dlg@40tude.net>, Joerg Meier 
(joergmmeier@arcor.de) says...

> Test code (ugly, but too lazy to clean it up):
> 
> <http://pastebin.com/TNj7Fmqy>

Somehow this reminds me to:
http://www.ibm.com/developerworks/java/library/j-jtp02225/index.html

Kind regards,
Wanja

-- 
"I'm going to put something to you here, and I think you'd better 
listen to this: If we race, if we two race, we could end up with
nothing, so it's up to Eddie. If we don't race each other , 
we've got an opportunity to get first and second." 
[Damon Hill, Spa '98, being chased by Ralf who is 5s faster than him]

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---

[toc] | [prev] | [standalone]


Page 3 of 3 — ← Prev page 1 2 [3]

Back to top | Article view | comp.lang.java.programmer


csiph-web