Search in sources :

Example 6 with PerformanceMeter

use of org.eclipse.test.performance.PerformanceMeter 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)

Example 7 with PerformanceMeter

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

the class Test_situational method test_createComposites.

/**
 * Situations:
 *
 * - Widget creation
 * - syncExec/asyncExec performance
 * - Image creation
 * - Drawing operations
 * - String measuring
 * - String drawing
 * - Region operations
 * - Fonts
 * - Image loading
 * - Layouts
 */
public void test_createComposites() {
    PerformanceMeter meter = createMeter("Create composites");
    int samples;
    Performance.getDefault();
    // Warm up.
    for (samples = 0; samples < 2; samples++) {
        Shell shell = new Shell(display);
        for (int i = 0; i < 100; i++) {
            Composite c = new Composite(shell, SWT.NONE);
            for (int j = 0; j < 10; j++) {
                new Composite(c, SWT.NONE);
            }
        }
        shell.dispose();
        while (display.readAndDispatch()) {
        /*empty*/
        }
    }
    for (samples = 0; samples < 100; samples++) {
        Shell shell = new Shell(display);
        meter.start();
        for (int i = 0; i < 100; i++) {
            Composite c = new Composite(shell, SWT.NONE);
            for (int j = 0; j < 50; j++) {
                new Composite(c, SWT.NONE);
            }
        }
        meter.stop();
        shell.dispose();
        while (display.readAndDispatch()) {
        /*empty*/
        }
    }
    disposeMeter(meter);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Composite(org.eclipse.swt.widgets.Composite) PerformanceMeter(org.eclipse.test.performance.PerformanceMeter)

Example 8 with PerformanceMeter

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

the class Test_situational method test_fastStringDrawing.

public void test_fastStringDrawing() {
    PerformanceMeter meter = createMeterWithoutSummary("Draw strings using GC.drawString()");
    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);
        Font font1 = new Font(display, "Helvetica", 20, SWT.NONE);
        Font font2 = new Font(display, "Helvetica", 10, SWT.BOLD);
        String testString = "The quick brown SWT jumped foxily over the lazy dog.";
        int x1 = 0, y1 = height / 2, x2 = width / 2, y2 = 0;
        meter.start();
        GC gc = new GC(c);
        for (int i = 0; i < 2000; i++) {
            x1 = (x1 + 5) % width;
            y1 = (y1 + 5) % height;
            x2 = (x2 + 5) % width;
            y2 = (y2 + 5) % height;
            gc.setFont((i & 1) == 0 ? font1 : font2);
            gc.setForeground((i & 1) == 0 ? color1 : color2);
            gc.stringExtent(testString);
            gc.drawString(testString, x1, y2);
            gc.drawString(testString, x1, y1, true);
        }
        gc.dispose();
        meter.stop();
        shell.dispose();
        color1.dispose();
        color2.dispose();
        font1.dispose();
        font2.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) GC(org.eclipse.swt.graphics.GC) Font(org.eclipse.swt.graphics.Font)

Example 9 with PerformanceMeter

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

the class Test_situational method test_imageDrawing.

public void test_imageDrawing() {
    PerformanceMeter meter = createMeter("Draw on an image");
    int samples;
    for (samples = 0; samples < 10; samples++) {
        int width = 640;
        int height = 480;
        Image image = new Image(display, width, height);
        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(image);
        for (int i = 0; i < 10000; 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();
        image.dispose();
        color1.dispose();
        color2.dispose();
        while (display.readAndDispatch()) {
        /*empty*/
        }
    }
    disposeMeter(meter);
}
Also used : Color(org.eclipse.swt.graphics.Color) PerformanceMeter(org.eclipse.test.performance.PerformanceMeter) Image(org.eclipse.swt.graphics.Image) GC(org.eclipse.swt.graphics.GC)

Aggregations

PerformanceMeter (org.eclipse.test.performance.PerformanceMeter)9 Shell (org.eclipse.swt.widgets.Shell)6 Color (org.eclipse.swt.graphics.Color)4 GC (org.eclipse.swt.graphics.GC)4 GridData (org.eclipse.swt.layout.GridData)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 Performance (org.eclipse.test.performance.Performance)4 Canvas (org.eclipse.swt.widgets.Canvas)3 Composite (org.eclipse.swt.widgets.Composite)3 Font (org.eclipse.swt.graphics.Font)2 Label (org.eclipse.swt.widgets.Label)2 Image (org.eclipse.swt.graphics.Image)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 Button (org.eclipse.swt.widgets.Button)1 Group (org.eclipse.swt.widgets.Group)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