package test; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; public class CalculateTest { Display display; Shell shell; Canvas canvas; private int MAX_BUTTON_NUM = 10; private int LOOP_COUNT = 1000; public static void main(String[] args) { CalculateTest application = new CalculateTest(); application.init(); application.run(); } public void init() { display = new Display(); shell = new Shell(display); shell.setText("Test resize performance"); createMenuBar(shell); createContentPane(shell); } private void createMenuBar(Shell shell) { Menu bar = new Menu(shell, SWT.BAR); shell.setMenuBar(bar); MenuItem item; Menu menu = new Menu(bar); MenuItem header = new MenuItem(bar, SWT.CASCADE); header.setText("Test"); header.setMenu(menu); item = new MenuItem(menu, SWT.PUSH); item.setText("Run test"); item.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { runTest(); } }); } public void run() { shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } private void createContentPane(Shell shell) { FillLayout fillLayout = new FillLayout(SWT.VERTICAL); shell.setLayout(fillLayout); for (int i = 0; i < MAX_BUTTON_NUM; i++) { //Button button = new Button(shell, SWT.NONE); //button.setText("Button " + i); CLabel label = new CLabel(shell, SWT.WRAP); label.setText("Text item " + i); } //canvas.setSize(50, 100); shell.pack(); //shell.setBounds(100, 100, 700, 600); } /** * Body of the test */ protected void runTest() { long start, stop; Control children[] = shell.getChildren(); int len = children.length; start = System.currentTimeMillis(); for (int i = 0; i < LOOP_COUNT; i++) { for (int j = 0; j