Search in sources :

Example 1 with Performance

use of org.eclipse.test.performance.Performance in project eclipse.platform.swt by eclipse.

the class Test_situational method test_windowDrawing.

public void test_windowDrawing() {
    PerformanceMeter meter = createMeter("Draw on a window");
    Performance performance = Performance.getDefault();
    performance.setComment(meter, Performance.EXPLAINS_DEGRADATION_COMMENT, "Regression due to a issue on the Releng test machine");
    int samples;
    for (samples = 0; samples < 10; samples++) {
        int width = 640;
        int height = 480;
        Shell shell = new Shell(display);
        shell.setLayout(new GridLayout());
        Canvas c = new Canvas(shell, SWT.NONE);
        GridData data = new GridData();
        data.widthHint = width;
        data.heightHint = height;
        c.setLayoutData(data);
        shell.pack();
        shell.open();
        while (display.readAndDispatch()) {
        /*empty*/
        }
        try {
            Thread.sleep(2000);
        } catch (Exception e) {
        }
        while (display.readAndDispatch()) {
        /*empty*/
        }
        Color color1 = new Color(display, 0xff, 0, 0xff);
        Color color2 = new Color(display, 0, 0xff, 0xff);
        int x1 = 0, y1 = height / 2, x2 = width / 2, y2 = 0;
        meter.start();
        GC gc = new GC(c);
        for (int i = 0; i < 6000; i++) {
            x1 = (x1 + 5) % width;
            y1 = (y1 + 5) % height;
            x2 = (x2 + 5) % width;
            y2 = (y2 + 5) % height;
            gc.setLineStyle(SWT.LINE_SOLID);
            gc.drawLine(x1, y1, x2, y2);
            gc.setForeground((i & 1) == 0 ? color1 : color2);
            gc.setBackground((i & 1) == 0 ? color1 : color2);
            gc.fillRectangle(x1, y1, 200, 200);
            gc.drawRoundRectangle(x2, y2, 200, 200, 50, 50);
            gc.setLineStyle(SWT.LINE_DASHDOT);
            gc.drawLine(x2, y1, x1, y2);
        }
        gc.dispose();
        meter.stop();
        shell.dispose();
        color1.dispose();
        color2.dispose();
        while (display.readAndDispatch()) {
        /*empty*/
        }
    }
    disposeMeter(meter);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) Canvas(org.eclipse.swt.widgets.Canvas) Color(org.eclipse.swt.graphics.Color) GridData(org.eclipse.swt.layout.GridData) PerformanceMeter(org.eclipse.test.performance.PerformanceMeter) Performance(org.eclipse.test.performance.Performance) GC(org.eclipse.swt.graphics.GC)

Example 2 with Performance

use of org.eclipse.test.performance.Performance in project eclipse.platform.swt by eclipse.

the class Test_situational method test_createWidgets.

public void test_createWidgets() {
    PerformanceMeter meter = createMeter("Create composites and widgets");
    int samples;
    Performance performance = Performance.getDefault();
    performance.tagAsGlobalSummary(meter, "Create composites and widgets", Dimension.ELAPSED_PROCESS);
    for (samples = 0; samples < 10; samples++) {
        Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());
        meter.start();
        for (int i = 0; i < 50; i++) {
            Composite c = new Composite(shell, SWT.NONE);
            for (int j = 0; j < 10; j++) {
                new Button(c, SWT.PUSH);
                new Label(c, SWT.NONE);
                new Scale(c, SWT.NONE);
                new ProgressBar(c, SWT.NONE);
                new List(c, SWT.NONE);
                new Text(c, SWT.SINGLE);
                new Text(c, SWT.MULTI);
                new Slider(c, SWT.NONE);
                new Tree(c, SWT.NONE);
                new Table(c, SWT.NONE);
                new TabFolder(c, SWT.NONE);
                new Group(c, SWT.BORDER);
                new Composite(c, SWT.NONE);
            }
        }
        meter.stop();
        shell.dispose();
        while (display.readAndDispatch()) {
        /*empty*/
        }
    }
    disposeMeter(meter);
}
Also used : Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) Slider(org.eclipse.swt.widgets.Slider) Label(org.eclipse.swt.widgets.Label) TabFolder(org.eclipse.swt.widgets.TabFolder) Scale(org.eclipse.swt.widgets.Scale) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) PerformanceMeter(org.eclipse.test.performance.PerformanceMeter) Tree(org.eclipse.swt.widgets.Tree) List(org.eclipse.swt.widgets.List) Performance(org.eclipse.test.performance.Performance) ProgressBar(org.eclipse.swt.widgets.ProgressBar)

Example 3 with Performance

use of org.eclipse.test.performance.Performance in project eclipse.platform.swt by eclipse.

the class SwtPerformanceTestCase method createMeter.

protected PerformanceMeter createMeter(String id) {
    Performance performance = Performance.getDefault();
    String scenarioId = "org.eclipse.swt.test." + id;
    PerformanceMeter meter = performance.createPerformanceMeter(scenarioId);
    performance.tagAsSummary(meter, id, Dimension.ELAPSED_PROCESS);
    return meter;
}
Also used : PerformanceMeter(org.eclipse.test.performance.PerformanceMeter) Performance(org.eclipse.test.performance.Performance)

Example 4 with Performance

use of org.eclipse.test.performance.Performance in project eclipse.platform.swt by eclipse.

the class SwtPerformanceTestCase method createMeterWithoutSummary.

protected PerformanceMeter createMeterWithoutSummary(String id) {
    Performance performance = Performance.getDefault();
    String scenarioId = "org.eclipse.swt.test." + id;
    PerformanceMeter meter = performance.createPerformanceMeter(scenarioId);
    return meter;
}
Also used : PerformanceMeter(org.eclipse.test.performance.PerformanceMeter) Performance(org.eclipse.test.performance.Performance)

Aggregations

Performance (org.eclipse.test.performance.Performance)4 PerformanceMeter (org.eclipse.test.performance.PerformanceMeter)4 Shell (org.eclipse.swt.widgets.Shell)2 Color (org.eclipse.swt.graphics.Color)1 GC (org.eclipse.swt.graphics.GC)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Canvas (org.eclipse.swt.widgets.Canvas)1 Composite (org.eclipse.swt.widgets.Composite)1 Group (org.eclipse.swt.widgets.Group)1 Label (org.eclipse.swt.widgets.Label)1 List (org.eclipse.swt.widgets.List)1 ProgressBar (org.eclipse.swt.widgets.ProgressBar)1 Scale (org.eclipse.swt.widgets.Scale)1 Slider (org.eclipse.swt.widgets.Slider)1 TabFolder (org.eclipse.swt.widgets.TabFolder)1 Table (org.eclipse.swt.widgets.Table)1 Text (org.eclipse.swt.widgets.Text)1