Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 42899 invoked from network); 13 Jun 2006 11:48:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Jun 2006 11:48:42 -0000 Received: (qmail 60135 invoked by uid 500); 13 Jun 2006 11:48:42 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 60103 invoked by uid 500); 13 Jun 2006 11:48:42 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 60092 invoked by uid 99); 13 Jun 2006 11:48:42 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jun 2006 04:48:42 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [209.237.227.198] (HELO brutus.apache.org) (209.237.227.198) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jun 2006 04:48:41 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 2DBFB7141F9 for ; Tue, 13 Jun 2006 11:47:30 +0000 (GMT) Message-ID: <10864202.1150199250157.JavaMail.jira@brutus> Date: Tue, 13 Jun 2006 11:47:30 +0000 (GMT+00:00) From: "Alexey Varlamov (JIRA)" To: harmony-commits@incubator.apache.org Subject: [jira] Updated: (HARMONY-589) [classlib][luni] java.lang.StringBuilder performs very slowly In-Reply-To: <32277562.1149923129783.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/HARMONY-589?page=all ] Alexey Varlamov updated HARMONY-589: ------------------------------------ Attachment: AbstractStringBuilder.java SB.diff 1) j.lAbstractStringBuilder is package-private class providing shared functionality for j.l.StringBuilder & j.l.StringBuffer. 2) > [classlib][luni] java.lang.StringBuilder performs very slowly > ------------------------------------------------------------- > > Key: HARMONY-589 > URL: http://issues.apache.org/jira/browse/HARMONY-589 > Project: Harmony > Type: Improvement > Components: Classlib > Reporter: Alexey Varlamov > Priority: Minor > Attachments: AbstractStringBuilder.java, SB.diff > > The j.l.StringBuilder was introduced in Java 1.5 mainly as a speedup replacement to heavily synchronized j.l.StringBuffer. > However, current implementation of StringBuilder performs 2-4 times slower than StringBuffer. > The following simple test demonstrates this: > public class SPTest { > public static void main(String[] s) { > test1(); > test2(); > } > > static void test1() { > long t1 = System.currentTimeMillis(); > StringBuilder sb1 = new StringBuilder(100000); > for(int i=0; i<10000; i++){ > sb1.append("0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"); > } > long t2 = System.currentTimeMillis(); > > StringBuffer sb2 = new StringBuffer(100000); > for(int i=0; i<10000; i++){ > sb2.append("0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"); > } > long t3 = System.currentTimeMillis(); > > System.out.println("append(String) test, ms"); > System.out.println("\tStringBuilder : " + (t2-t1)); > System.out.println("\tStringBuffer : " + (t3-t2)); > } > > static void test2() { > long t1 = System.currentTimeMillis(); > String s1 = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"; > for(int i=0; i<1000; i++){ > s1 = new StringBuilder(s1).append("1234567890").toString(); > } > long t2 = System.currentTimeMillis(); > String s2 = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"; > for(int i=0; i<1000; i++){ > s2 = new StringBuffer(s2).append("1234567890").toString(); > } > long t3 = System.currentTimeMillis(); > System.out.println("constructor(String) test, ms"); > System.out.println("\tStringBuilder : " + (t2-t1)); > System.out.println("\tStringBuffer : " + (t3-t2)); > } > } > Typical output on J9vm, interpreter mode: > --------------------------------- > append(String) test, ms > StringBuilder : 221 > StringBuffer : 140 > constructor(String) test, ms > StringBuilder : 1051 > StringBuffer : 291 > --------------------------------- > J9vm, JIT mode: > --------------------------------- > append(String) test, ms > StringBuilder : 80 > StringBuffer : 30 > constructor(String) test, ms > StringBuilder : 130 > StringBuffer : 40 > -------------------------------- > Jrockit 1.5.0 output: > -------------------------------- > append(String) test, ms > StringBuilder : 10 > StringBuffer : 20 > constructor(String) test, ms > StringBuilder : 30 > StringBuffer : 40 > Patch to fix this will follow. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira