01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tctest;
05:
06: import com.tc.object.BaseDSOTestCase;
07:
08: /*
09: * Unit test for measuring the overhead of StringBuffer for jdk1.5.
10: */
11: public class StringBufferPerformance15Test extends BaseDSOTestCase {
12: private final static int COUNT = 100000;
13:
14: public void test() {
15: StringBuffer sb = new StringBuffer();
16: char[] appendString = new char[] { 't', 'h', 'i', 's', ' ',
17: 'i', 's', ' ', 'a', ' ', 't', 'e', 's', 't' };
18: long startTime = System.currentTimeMillis();
19: for (int i = 0; i < COUNT; i++) {
20: sb.append(appendString);
21: }
22: long endTime = System.currentTimeMillis();
23: System.out.println("Time elapsed for non-shared StringBuffer: "
24: + (endTime - startTime) + " ms.");
25: }
26:
27: }
|