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 149421 Details for
Bug 292108
Unguarded access to static map in ThemeManager could lead to application crash
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Testcase for performance impacts
clipboard.txt (text/plain), 3.23 KB, created by
Stefan Röck
on 2009-10-13 05:10:06 EDT
(
hide
)
Description:
Testcase for performance impacts
Filename:
MIME Type:
Creator:
Stefan Röck
Created:
2009-10-13 05:10:06 EDT
Size:
3.23 KB
patch
obsolete
>package org.eclipse.rwt.internal.theme; > >import java.util.Random; > >import junit.framework.TestCase; > >import org.eclipse.swt.RWTFixture; >import org.eclipse.swt.SWT; >import org.eclipse.swt.widgets.Control; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Shell; > >public class ThemeManagerTest extends TestCase{ > > public static final class ThreadRunnable implements Runnable { > private final int iterations; > private final Class[] widgetList; > private final ThemeManager mgr; > private final Random r = new Random(); > > public ThreadRunnable(final int iterations, final Class[] widgetList, > final ThemeManager mgr) { > this.iterations = iterations; > this.widgetList = widgetList; > this.mgr = mgr; > } > > public void run() { > int c = 0; > while (c++ < iterations) { > final int idx = r.nextInt(widgetList.length); > mgr.getThemeAdapter(widgetList[idx]); > try { > Thread.sleep(10); > } catch (final InterruptedException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } > } > } > > protected void setUp() throws Exception { > RWTFixture.setUp(); > } > > protected void tearDown() throws Exception { > RWTFixture.tearDown(); > } > > public void testGetThemeAdapterPerformance() throws InterruptedException { > final Display display = new Display(); > final Shell parent = new Shell(display, SWT.NONE); > > final ThemeManager mgr = ThemeManager.getInstance(); > final IThemeAdapter adapter = new IThemeAdapter() { > }; > > mgr.adapters.put(Control.class, adapter); > > final int controlCount = 300; > final int customControlCount = 10; > final int iterations = 100; > final int threadCount = 10; > > final Class[] widgetList = new Class[controlCount + customControlCount]; > // Put many Wigets to simulate a lot of reads > for (int i=0; i<controlCount; i++) { > widgetList[i] = Control.class; > } > > // add some widgets that are not in list to simulated map changes > widgetList[controlCount + 0] = new Control(parent, SWT.NONE) {}.getClass(); > widgetList[controlCount + 1] = new Control(parent, SWT.NONE) {}.getClass(); > widgetList[controlCount + 2] = new Control(parent, SWT.NONE) {}.getClass(); > widgetList[controlCount + 3] = new Control(parent, SWT.NONE) {}.getClass(); > widgetList[controlCount + 4] = new Control(parent, SWT.NONE) {}.getClass(); > widgetList[controlCount + 5] = new Control(parent, SWT.NONE) {}.getClass(); > widgetList[controlCount + 6] = new Control(parent, SWT.NONE) {}.getClass(); > widgetList[controlCount + 7] = new Control(parent, SWT.NONE) {}.getClass(); > widgetList[controlCount + 8] = new Control(parent, SWT.NONE) {}.getClass(); > widgetList[controlCount + 9] = new Control(parent, SWT.NONE) {}.getClass(); > > final Runnable runnable = new ThreadRunnable(iterations, widgetList, mgr); > > // Create some Threads > final Thread[] threadLst = new Thread[threadCount]; > for (int i = 0; i<threadCount; i++) { > final Thread t = new Thread(runnable); > threadLst[i] = t; > t.start(); > } > > // Wait for all threads to be ready > for (int i = 0; i<threadCount; i++) { > threadLst[i].join(); > } > > } >}
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 292108
: 149421