Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

PerformanceTestLabelsAndOrderedLayouts.java 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package com.vaadin.tests;
  2. import java.util.Date;
  3. import com.vaadin.shared.ui.ContentMode;
  4. import com.vaadin.ui.AbstractOrderedLayout;
  5. import com.vaadin.ui.Button;
  6. import com.vaadin.ui.CustomComponent;
  7. import com.vaadin.ui.Label;
  8. import com.vaadin.ui.VerticalLayout;
  9. public class PerformanceTestLabelsAndOrderedLayouts extends CustomComponent {
  10. private final AbstractOrderedLayout main;
  11. private final AbstractOrderedLayout testContainer = new VerticalLayout();
  12. private Date startTime;
  13. private final Label result;
  14. private static final String DESCRIPTION = "Simple test that renders n labels into ordered layout.";
  15. private static final int INITIAL_COMPONENTS = 1000;
  16. public PerformanceTestLabelsAndOrderedLayouts() {
  17. main = new VerticalLayout();
  18. setCompositionRoot(main);
  19. addInfo();
  20. result = new Label();
  21. main.addComponent(result);
  22. main.addComponent(
  23. new Button("click when rendered", event -> endTest()));
  24. main.addComponent(
  25. new Button("Click for layout repaint (cached components)",
  26. event -> testContainer.markAsDirty()));
  27. for (int i = 0; i < INITIAL_COMPONENTS; i++) {
  28. Label l = new Label("foo" + i);
  29. testContainer.addComponent(l);
  30. }
  31. main.addComponent(testContainer);
  32. startTest();
  33. }
  34. public void startTest() {
  35. startTime = new Date();
  36. }
  37. public void endTest() {
  38. final long millis = (new Date()).getTime() - startTime.getTime();
  39. final Float f = new Float(millis / 1000.0);
  40. result.setValue("Test completed in " + f + " seconds");
  41. }
  42. private void addInfo() {
  43. main.addComponent(new Label(DESCRIPTION, ContentMode.HTML));
  44. }
  45. }