Benchmark.java (e4b83892) Benchmark.java (9edf8282)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 30 unchanged lines hidden (view full) ---

39import org.junit.Rule;
40import org.junit.Test;
41import org.junit.rules.TestName;
42import org.openoffice.test.OpenOffice;
43import org.openoffice.test.common.Condition;
44import org.openoffice.test.common.DataSheet;
45import org.openoffice.test.common.GraphicsUtil;
46import org.openoffice.test.common.Logger;
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 30 unchanged lines hidden (view full) ---

39import org.junit.Rule;
40import org.junit.Test;
41import org.junit.rules.TestName;
42import org.openoffice.test.OpenOffice;
43import org.openoffice.test.common.Condition;
44import org.openoffice.test.common.DataSheet;
45import org.openoffice.test.common.GraphicsUtil;
46import org.openoffice.test.common.Logger;
47import org.openoffice.test.common.SystemUtil;
48
49
50public class Benchmark {
51 @Rule
52 public Logger log = Logger.getLogger(this);
53
54 @Rule
55 public TestName testname = new TestName();
56
57 private static DataSheet result;
58
47
48
49public class Benchmark {
50 @Rule
51 public Logger log = Logger.getLogger(this);
52
53 @Rule
54 public TestName testname = new TestName();
55
56 private static DataSheet result;
57
59 private static final double INTERVAL = 0.1;
58 private static final double INTERVAL = 0.1;
60
59
60 private static int repeat = 8;
61
61 public Benchmark() {
62
63 }
64
65 @BeforeClass
66 public static void beforeClass() throws Exception {
62 public Benchmark() {
63
64 }
65
66 @BeforeClass
67 public static void beforeClass() throws Exception {
67 result = new DataSheet(getFile("output/pvt_gui_benchmark.xml"), "benckmark");
68 OpenOffice.killAll();
68 OpenOffice.killAll();
69 result.addRow("Scenario", "No", "Consumed Time", "Memory(VSZ)", "Memory(RSS)", "Handles(Windows Only)");
69 result = new DataSheet(getFile("output/pvt_gui_benchmark.xml"), true);
70 result.addRow("data", "Scenario", "No", "Consumed Time", "Memory(VSZ)", "Memory(RSS)", "Handles(Windows Only)");
70 }
71
72 @AfterClass
73 public static void afterClass() throws Exception {
71 }
72
73 @AfterClass
74 public static void afterClass() throws Exception {
74 app.close();
75 app.stop();
75 }
76
76 }
77
77 private HashMap<String, Object> getPerfData() {
78 HashMap<String, Object> proccessInfo = SystemUtil.findProcess(".*(soffice\\.bin|soffice\\.exe .*-env).*");
79 String pid = (String) proccessInfo.get("pid");
80 return SystemUtil.getProcessPerfData(pid);
81 }
82
83 private void addRecord(int i, long start, long end) {
78 private void addRecord(int i, long start, long end) {
84 HashMap<String, Object> perf = getPerfData();
85 result.addRow(testname.getMethodName(), i, (end - start), perf.get("vsz"), perf.get("rss"), perf.get("handles"));
79 sleep(2);
80 HashMap<String, Object> perf = aoo.getPerfData();
81 result.addRow("data", testname.getMethodName(), i, (end - start), perf.get("vsz"), perf.get("rss"), perf.get("handles"));
86 }
87
88 @Test
89 public void coolStartup() throws Exception {
82 }
83
84 @Test
85 public void coolStartup() throws Exception {
90 aoo.kill();
91 aoo.cleanUserInstallation();
92 aoo.start();
93 long start = System.currentTimeMillis();
94 startcenter.waitForExistence(120, INTERVAL);
95 long end = System.currentTimeMillis();
96 sleep(2);
97 addRecord(0, start, end);
98 app.close();
86 app.stop();
87 for (int i = 0; i < repeat; i++) {
88 aoo.cleanUserInstallation();
89 assertFalse("User profile exists", aoo.getUserInstallation().exists());
90 aoo.start();
91 long start = System.currentTimeMillis();
92 startcenter.waitForExistence(120, INTERVAL);
93 long end = System.currentTimeMillis();
94 addRecord(i, start, end);
95 app.quit();
96 }
99 }
100
101 @Test
102 public void warmStartup() throws Exception {
97 }
98
99 @Test
100 public void warmStartup() throws Exception {
103 for (int i = 0; i < 8; i++) {
104 aoo.kill();//make sure app is closed
101 // Make sure we has generated user profile
102 app.start(true);
103 app.quit();
104
105 for (int i = 0; i < repeat; i++) {
106 assertTrue("User profile exists", aoo.getUserInstallation().exists());
105 aoo.start();
106 long start = System.currentTimeMillis();
107 startcenter.waitForExistence(120, INTERVAL);
108 long end = System.currentTimeMillis();
107 aoo.start();
108 long start = System.currentTimeMillis();
109 startcenter.waitForExistence(120, INTERVAL);
110 long end = System.currentTimeMillis();
109 sleep(2);
110 addRecord(i, start, end);
111 addRecord(i, start, end);
111 app.close();
112 app.quit();
112 }
113 }
114
115 @Test
116 public void newTextDocument() {
113 }
114 }
115
116 @Test
117 public void newTextDocument() {
117 for (int i = 0; i < 8; i++) {
118 aoo.kill();//make sure app is closed
119 aoo.start();
120 startCenterWriterButton.waitForExistence(120, 1);
121 sleep(2);
118 app.start(true);
119 app.quit();
120
121 for (int i = 0; i < repeat; i++) {
122 app.start();
122 startCenterWriterButton.click(0.5, 0.5);
123 long start = System.currentTimeMillis();
124 writer.waitForExistence(60, INTERVAL);
125 long end = System.currentTimeMillis();
123 startCenterWriterButton.click(0.5, 0.5);
124 long start = System.currentTimeMillis();
125 writer.waitForExistence(60, INTERVAL);
126 long end = System.currentTimeMillis();
126 sleep(2);
127 addRecord(i, start, end);
127 addRecord(i, start, end);
128 app.close();
128 app.quit();
129 }
130 }
131
132 @Test
133 public void newSpreadsheet() {
129 }
130 }
131
132 @Test
133 public void newSpreadsheet() {
134 for (int i = 0; i < 8; i++) {
135 aoo.kill();//make sure app is closed
136 aoo.start();
137 startCenterCalcButton.waitForExistence(120, 1);
138 sleep(2);
134 app.start(true);
135 app.quit();
136 for (int i = 0; i < repeat; i++) {
137 app.start();
139 startCenterCalcButton.click(0.5, 0.5);
140 long start = System.currentTimeMillis();
141 calc.waitForExistence(60, INTERVAL);
142 long end = System.currentTimeMillis();
138 startCenterCalcButton.click(0.5, 0.5);
139 long start = System.currentTimeMillis();
140 calc.waitForExistence(60, INTERVAL);
141 long end = System.currentTimeMillis();
143 sleep(2);
144 addRecord(i, start, end);
142 addRecord(i, start, end);
145 app.close();
143 app.quit();
146 }
147 }
148
149 @Test
150 public void newPresentation() {
144 }
145 }
146
147 @Test
148 public void newPresentation() {
151 for (int i = 0; i < 8; i++) {
152 aoo.kill();//make sure app is closed
153 aoo.start();
154 startCenterImpressButton.waitForExistence(120, 1);
155 sleep(2);
149 app.start(true);
150 app.quit();
151 for (int i = 0; i < repeat; i++) {
152 app.start();
156 startCenterImpressButton.click(0.5, 0.5);
153 startCenterImpressButton.click(0.5, 0.5);
157 sleep(1);
158 presentationWizard.click(0.9, 0.95);
159 long start = System.currentTimeMillis();
160 impress.waitForExistence(60, INTERVAL);
161 long end = System.currentTimeMillis();
154 presentationWizard.click(0.9, 0.95);
155 long start = System.currentTimeMillis();
156 impress.waitForExistence(60, INTERVAL);
157 long end = System.currentTimeMillis();
158 addRecord(i, start, end);
159 app.quit();
160 }
161 }
162
163 @Test
164 public void slideShow() {
165 app.start(true);
166 app.quit();
167
168 String path = prepareData("pvt/slideshow.odp");
169 final Rectangle rect = GraphicsUtil.getScreenRectangle();
170 // when slide show is running, top-center area will be filled with green
171 rect.setRect(rect.getCenterX(), 2, 2, 2);
172 for (int i = 0; i < repeat; i++) {
173 app.start();
174 open(path);
175 impress.waitForExistence(60, 1);
162 sleep(2);
176 sleep(2);
177 assertFalse("Slideshow control exists", slideShow.exists());
178 assertFalse("Slideshow is not started", GraphicsUtil.isFilledWith(0xFF00FF00, rect));
179 typeKeys("<F5>");
180 long start = System.currentTimeMillis();
181 new Condition() {
182 @Override
183 public boolean value() {
184 return GraphicsUtil.isFilledWith(0xFF00FF00, rect);
185 }
186
187 }.waitForTrue("", 120, INTERVAL);
188 long end = System.currentTimeMillis();
163 addRecord(i, start, end);
189 addRecord(i, start, end);
164 app.close();
190 slideShow.typeKeys("<esc>");
191 sleep(2);
192 app.quit();
165 }
166 }
167
168 @Test
169 public void loadFinishPlainODT() {
170 loadFinish("pvt/plain_200p.odt", "Page 1 / 23[0-9]{1}");
171 }
172

--- 38 unchanged lines hidden (view full) ---

211 }
212
213 @Test
214 public void loadFinishComplexDOC() {
215 loadFinish("pvt/complex_300p.doc", "Page 1 / 3[0-9]{2}");
216 }
217
218 @Test
193 }
194 }
195
196 @Test
197 public void loadFinishPlainODT() {
198 loadFinish("pvt/plain_200p.odt", "Page 1 / 23[0-9]{1}");
199 }
200

--- 38 unchanged lines hidden (view full) ---

239 }
240
241 @Test
242 public void loadFinishComplexDOC() {
243 loadFinish("pvt/complex_300p.doc", "Page 1 / 3[0-9]{2}");
244 }
245
246 @Test
219 public void loadFinishComplexODT() {
220 loadFinish("pvt/complex_800p.odt", "Page 1 / 8[0-9]{2}");
247 public void loadFinishComplexDOCX() {
248 loadFinish("pvt/complex_400p.doc", "Page 1 / 4[0-9]{2}");
221 }
222
223 @Test
249 }
250
251 @Test
224 public void loadFinishComplexXLS() {
225 loadFinish("pvt/sc_complex_13sh_4kcell.xls", "Sheet 2 / 13");
252 public void loadFinishComplexODT() {
253 loadFinish("pvt/complex_800p.odt", "Page 1 / 8[0-9]{2}");
226 }
227
228 @Test
229 public void loadFinishComplexODS() {
254 }
255
256 @Test
257 public void loadFinishComplexODS() {
230 loadFinish("pvt/sc_complex_13sh_4kcell_new_odf1.2.ods", "Sheet 6 / 13");
258 loadFinish("pvt/complex_19s.odt", "Sheet 8 / 19");
231 }
259 }
232
233
234 @Test
235 public void loadFinishComplexODP() {
260
261 @Test
262 public void loadFinishComplexODP() {
236 loadFinish("pvt/sd_complex_51p_odf1.2.odp", "Slide 1 / 51");
263 loadFinish("pvt/complex_150p.odp", "Slide 1 / 150");
237 }
238
264 }
265
239 @Test
240 public void loadFinishComplexPPT() {
241 loadFinish("pvt/sd_complex_51p.ppt", "Slide 1 / 51");
242 }
243
244 public void loadFinish(String file, final String indicator) {
245 final int openIndicatorIndex = file.matches(".*\\.(odp|ppt|pptx)$") ? 4 : 0;
246 String path = prepareData(file);
266 public void loadFinish(String file, final String indicator) {
267 final int openIndicatorIndex = file.matches(".*\\.(odp|ppt|pptx)$") ? 4 : 0;
268 String path = prepareData(file);
247 aoo.kill();
248 app.start();
249 startcenter.waitForExistence(10, 1);
250 sleep(2); // Give some seconds to AOO relax. We want data more stable.
269 app.stop();
251 for (int i = 0; i < 8; i++) {
270 for (int i = 0; i < 8; i++) {
271 app.start();
252 app.dispatch(".uno:Open");
253 filePickerPath.setText(path);
272 app.dispatch(".uno:Open");
273 filePickerPath.setText(path);
254 sleep(2);
274 sleep(1);
255 filePickerOpen.click(0.5, 0.5);
256 long start = System.currentTimeMillis();
257 new Condition() {
258 @Override
259 public boolean value() {
260 try {
261 String text = statusBar.getItemText(openIndicatorIndex);
262 return text.matches(indicator);
263 } catch (Exception e) {
264 return false;
265 }
266 }
267
268 }.waitForTrue("", 120, INTERVAL);
269 long end = System.currentTimeMillis();
275 filePickerOpen.click(0.5, 0.5);
276 long start = System.currentTimeMillis();
277 new Condition() {
278 @Override
279 public boolean value() {
280 try {
281 String text = statusBar.getItemText(openIndicatorIndex);
282 return text.matches(indicator);
283 } catch (Exception e) {
284 return false;
285 }
286 }
287
288 }.waitForTrue("", 120, INTERVAL);
289 long end = System.currentTimeMillis();
270 sleep(2);
271 addRecord(i, start, end);
272 discard();
290 addRecord(i, start, end);
291 discard();
292 app.quit();
273 }
293 }
274
275 app.close();
276 }
277
278 @Test
279 public void savePlainDOC() {
280 save("pvt/plain_50p.doc", "Page i / 5[0-9]{1}");
281 }
282
283 @Test

--- 17 unchanged lines hidden (view full) ---

301 }
302
303 @Test
304 public void savePlainODS() {
305 save("pvt/plain_11s.ods", "Sheet 1 / 11");
306 }
307
308 @Test
294 }
295
296 @Test
297 public void savePlainDOC() {
298 save("pvt/plain_50p.doc", "Page i / 5[0-9]{1}");
299 }
300
301 @Test

--- 17 unchanged lines hidden (view full) ---

319 }
320
321 @Test
322 public void savePlainODS() {
323 save("pvt/plain_11s.ods", "Sheet 1 / 11");
324 }
325
326 @Test
309 public void saveComplexXLS() {
310 save("pvt/sc_complex_13sh_4kcell.xls", "Sheet 2 / 13");
311 }
312
313 @Test
314 public void saveComplexODS() {
327 public void saveComplexODS() {
315 save("pvt/sc_complex_13sh_4kcell_new_odf1.2.ods", "Sheet 6 / 13");
328 save("pvt/complex_19s.ods", "Sheet 8 / 19");
316 }
317
318 @Test
319 public void savePlainODP() {
320 save("pvt/plain_200p.odp", "Slide 1 / 200");
321 }
322
323 @Test
324 public void savePlainPPT() {
325 save("pvt/plain_200p.ppt", "Slide 1 / 200");
326 }
327
328 @Test
329 public void saveComplexODP() {
329 }
330
331 @Test
332 public void savePlainODP() {
333 save("pvt/plain_200p.odp", "Slide 1 / 200");
334 }
335
336 @Test
337 public void savePlainPPT() {
338 save("pvt/plain_200p.ppt", "Slide 1 / 200");
339 }
340
341 @Test
342 public void saveComplexODP() {
330 save("pvt/sd_complex_51p_odf1.2.odp", "Slide 1 / 51");
343 save("pvt/complex_150p.odp", "Slide 1 / 150");
331 }
332
344 }
345
333 @Test
334 public void saveComplexPPT() {
335 save("pvt/sd_complex_51p.ppt", "Slide 1 / 51");
336 }
337
338 public void save(String file, final String openIndicator) {
339 boolean alienFormat = file.matches(".*\\.(doc|xls|ppt|docx|xlsx|pptx)$");
340 final int openIndicatorIndex = file.matches(".*\\.(odp|ppt|pptx)$") ? 4 : 0;
341 final int saveIndicatorIndex = file.matches(".*\\.(odt|doc|docx)$") ? 5 : file.matches(".*\\.(ods|xls|xlsx)$") ? 4 : 2;
346 public void save(String file, final String openIndicator) {
347 boolean alienFormat = file.matches(".*\\.(doc|xls|ppt|docx|xlsx|pptx)$");
348 final int openIndicatorIndex = file.matches(".*\\.(odp|ppt|pptx)$") ? 4 : 0;
349 final int saveIndicatorIndex = file.matches(".*\\.(odt|doc|docx)$") ? 5 : file.matches(".*\\.(ods|xls|xlsx)$") ? 4 : 2;
342 aoo.kill();
343 app.start();
350 app.stop();
344 String picture = prepareData("image/red_64x64.bmp");
351 String picture = prepareData("image/red_64x64.bmp");
345 for (int i = 0; i < 8; i++) {
352 for (int i = 0; i < repeat; i++) {
346 String dir = "temp/file" + i;
347 getFile(dir).mkdirs();
353 String dir = "temp/file" + i;
354 getFile(dir).mkdirs();
355 app.start();
348 open(prepareData(file, dir));
349 new Condition() {
350 @Override
351 public boolean value() {
352 try {
353 String text = statusBar.getItemText(openIndicatorIndex);
354 return text.matches(openIndicator);
355 } catch (Exception e) {

--- 22 unchanged lines hidden (view full) ---

378 return " ".equals(text);
379 } catch (Exception e) {
380 return false;
381 }
382 }
383
384 }.waitForTrue("", 120, INTERVAL);
385 long end = System.currentTimeMillis();
356 open(prepareData(file, dir));
357 new Condition() {
358 @Override
359 public boolean value() {
360 try {
361 String text = statusBar.getItemText(openIndicatorIndex);
362 return text.matches(openIndicator);
363 } catch (Exception e) {

--- 22 unchanged lines hidden (view full) ---

386 return " ".equals(text);
387 } catch (Exception e) {
388 return false;
389 }
390 }
391
392 }.waitForTrue("", 120, INTERVAL);
393 long end = System.currentTimeMillis();
386 sleep(2);
387 addRecord(i, start, end);
388 close();
394 addRecord(i, start, end);
395 close();
389 }
390
391 app.close();
396 app.stop();
397 }
392 }
398 }
393
394 @Test
395 public void slideShow() {
396 aoo.kill();
397 app.start();
398 String path = prepareData("pvt/sd_slideshow.odp");
399 final Rectangle rect = GraphicsUtil.getScreenRectangle();
400 // when slide show is running, top-center area will be filled with green
401 rect.setRect(rect.getCenterX(), 2, 2, 2);
402 for (int i = 0; i < 8; i++) {
403 open(path);
404 impress.waitForExistence(60, 1);
405 sleep(2);
406 assertFalse("Slideshow control exists", slideShow.exists());
407 assertFalse("Slideshow is not started", GraphicsUtil.isFilledWith(0xFF00FF00, rect));
408 typeKeys("<F5>");
409 long start = System.currentTimeMillis();
410 new Condition() {
411 @Override
412 public boolean value() {
413 return GraphicsUtil.isFilledWith(0xFF00FF00, rect);
414 }
415
416 }.waitForTrue("", 120, INTERVAL);
417 long end = System.currentTimeMillis();
418 sleep(2);
419 addRecord(i, start, end);
420 slideShow.typeKeys("<esc>");
421 sleep(2);
422 close();
423 }
424 app.close();
425 }
426}
399}