Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 150740 Details for
Bug 245008
Workspace's ElementTree object holding 500MB in large workspace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Benchmark of string shortening
BenchMisc.java (text/x-java), 2.10 KB, created by
John Arthorne
on 2009-10-28 11:41:36 EDT
(
hide
)
Description:
Benchmark of string shortening
Filename:
MIME Type:
Creator:
John Arthorne
Created:
2009-10-28 11:41:36 EDT
Size:
2.10 KB
patch
obsolete
>/********************************************************************** > * Copyright (c) 2009 IBM Corporation and others. All rights reserved. This > * program and the accompanying materials are made available under the terms of > * the Common Public License v1.0 which accompanies this distribution, and is > * available at http://www.eclipse.org/legal/cpl-v10.html > * > * Contributors: > * IBM - Initial API and implementation > **********************************************************************/ >package org.johna.perf; > >import java.lang.reflect.Field; > >public final class BenchMisc { > private static final int LOOPS = 1000000; > > public static final void main(final String[] args) { > try { > new BenchMisc().bench(); > } catch (Exception e) { > e.printStackTrace(); > } > } > > private static String stringSnip1(String string) { > return new String(string); > } > > private static String stringSnip2(String name) throws Exception { > Class c = String.class; > Field fldValue = c.getDeclaredField("value"); //$NON-NLS-1$ > fldValue.setAccessible(true); > Object o = fldValue.get(name); > if (o != null) { > char[] value = (char[]) o; > if (value.length != name.length()) { > name = new String(name); > } > } > return name; > } > > public void bench() throws Exception{ > String[] inputs = new String[] {"string1", "anotherstring", "yetanotherstring", "onemore string"}; >// String[] inputs = new String[] {"string1".substring(3), "anotherstring".substring(1), "yetanotherstring".substring(4), "onemore string".substring(1)}; > System.out.print("simple: "); > int loop = 0; > long startTime = System.currentTimeMillis(); > while (loop++ < LOOPS) { > for (int i = 0; i < inputs.length; i++) { > stringSnip1(inputs[i]); > } > } > System.out.println((System.currentTimeMillis() - startTime) + "ms"); > > System.out.print("reflection: "); > loop = 0; > startTime = System.currentTimeMillis(); > while (loop++ < LOOPS) { > for (int i = 0; i < inputs.length; i++) { > stringSnip2(inputs[i]); > } > } > System.out.println((System.currentTimeMillis() - startTime) + "ms"); > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 245008
:
110723
|
110817
|
148334
|
148627
|
148779
| 150740 |
175560
|
175565
|
175704
|
175730
|
175795
|
175798