FileDocCategorySizeDatePackage
TableTest.javaAPI DocAzureus 3.0.3.44560Mon Jul 17 23:53:48 BST 2006org.gudy.azureus2.ui.swt.test

TableTest

public class TableTest extends Object
author
TuxPaper
created
Jul 18, 2006

Fields Summary
static Table
tableNormal
private static Table
tableVirtual
static Display
display
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

		display = Display.getDefault();

		Shell shell = new Shell(display, SWT.SHELL_TRIM);
		shell.setLayout(new FillLayout());

		tableNormal = new Table(shell, SWT.BORDER);
		tableVirtual = new Table(shell, SWT.BORDER | SWT.VIRTUAL);

		Button btnStart = new Button(shell, SWT.PUSH);
		btnStart.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				runtest();
			}
		});

		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	
protected static voidruntest()

		tableNormal.clearAll();
		waitForComplete();
		runtest1();

		tableNormal.clearAll();
		waitForComplete();

		runtest2();

		tableNormal.clearAll();
		waitForComplete();
		runtest3();

		tableNormal.clearAll();
		waitForComplete();
		runtest4();
		
		tableNormal.clearAll();
		waitForComplete();
		runtest5();

		tableNormal.clearAll();
		waitForComplete();
		runtest6();

		tableNormal.clearAll();
		waitForComplete();
		runtest7();
	
static voidruntest1()

		long lStartTime = System.currentTimeMillis();

		for (int i = 0; i < 500; i++) {
			new TableItem(tableNormal, SWT.None);
		}
		waitForComplete();

		long lEndTime = System.currentTimeMillis();
		System.out.println("NVI: " + (lEndTime - lStartTime));
	
static voidruntest2()

		long lStartTime = System.currentTimeMillis();

		tableNormal.setItemCount(500);
		waitForComplete();

		long lEndTime = System.currentTimeMillis();
		System.out.println("NVS: " + (lEndTime - lStartTime));
		
	
static voidruntest3()

		long lStartTime = System.currentTimeMillis();

		for (int i = 0; i < 500; i++) {
			new TableItem(tableVirtual, SWT.None);
		}
		waitForComplete();

		long lEndTime = System.currentTimeMillis();
		System.out.println("VI:" + (lEndTime - lStartTime));
	
static voidruntest4()

		long lStartTime = System.currentTimeMillis();

		tableVirtual.setItemCount(500);
		
		waitForComplete();

		long lEndTime = System.currentTimeMillis();
		System.out.println("Vs:" + (lEndTime - lStartTime));
	
static voidruntest5()

		tableNormal.setItemCount(1000);
		waitForComplete();

		long lStartTime = System.currentTimeMillis();
		
		tableNormal.setItemCount(500);

		long lEndTime = System.currentTimeMillis();
		System.out.println("NVD1: " + (lEndTime - lStartTime));
		
	
static voidruntest6()

		tableNormal.setItemCount(1000);
		waitForComplete();

		long lStartTime = System.currentTimeMillis();
		
		for (int i = 0; i < 500; i++) {
			tableNormal.getItem(2).dispose();
		}

		long lEndTime = System.currentTimeMillis();
		System.out.println("NVD2: " + (lEndTime - lStartTime));
	
static voidruntest7()

		tableNormal.setItemCount(1000);
		waitForComplete();


		int indexes[] = new int[500];
		for (int i = 0; i < 200; i++) {
			indexes[i] = i * 2;
		}
		int x = 400;
		for (int i = 200; i < 500; i++) {
			indexes[i] = x++;
		}

		long lStartTime = System.currentTimeMillis();
		
		tableNormal.remove(indexes);

		long lEndTime = System.currentTimeMillis();
		System.out.println("NVD3: " + (lEndTime - lStartTime));
	
static voidwaitForComplete()

		while (display.readAndDispatch()) {}