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;
}
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);
}
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);
}
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);
}
Aggregations