Test the time to render a drawable component. @param drawable
(Drawable drawable)
| 381 | * @param drawable |
| 382 | */ |
| 383 | public static void timingTest(Drawable drawable) { |
| 384 | DrawingPanel dp = new DrawingPanel(); |
| 385 | DrawingFrame df = new DrawingFrame(dp); |
| 386 | df.setVisible(true); |
| 387 | dp.addDrawable(drawable); |
| 388 | dp.scale(); |
| 389 | dp.setPixelScale(); |
| 390 | Graphics g2 = dp.getGraphics(); |
| 391 | if (g2 == null) { |
| 392 | return; |
| 393 | } |
| 394 | long startTime = System.currentTimeMillis(); |
| 395 | drawable.draw(dp, g2); // first drawing often takes longer because of initialization |
| 396 | System.out.print("first drawing=" + (System.currentTimeMillis() - startTime)); //$NON-NLS-1$ |
| 397 | startTime = System.currentTimeMillis(); // reset the time |
| 398 | for (int i = 0; i < 5; i++) { |
| 399 | drawable.draw(dp, g2); |
| 400 | } |
| 401 | System.out.println(" avg time/drawing=" + ((System.currentTimeMillis() - startTime) / 5)); //$NON-NLS-1$ |
| 402 | g2.dispose(); |
| 403 | } |
| 404 | |
| 405 | /** |
| 406 | * Saves the contents of the specified component in the given file format. Note |
nothing calls this directly
no test coverage detected