diff options
author | Henri Sara <henri.sara@gmail.com> | 2017-03-16 10:23:02 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2017-03-16 10:23:02 +0200 |
commit | 28a815fb833087c1825365ac9b22c097e6d28ca5 (patch) | |
tree | 97691c8ae07c63c8f1939ffb53b9c9d9b0506978 /uitest | |
parent | 71679dfd1626737081b86127e6c547e37c77923f (diff) | |
download | vaadin-framework-28a815fb833087c1825365ac9b22c097e6d28ca5.tar.gz vaadin-framework-28a815fb833087c1825365ac9b22c097e6d28ca5.zip |
Remove unnecessary width calculation on Grid initial render (#8848)
Do not calculate column widths unnecessarily, especially for columns
with fixed width.
Fixes #8678
Diffstat (limited to 'uitest')
4 files changed, 176 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridManyColumns.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridManyColumns.java new file mode 100644 index 0000000000..7dca082a62 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridManyColumns.java @@ -0,0 +1,27 @@ +package com.vaadin.tests.components.grid; + +import java.util.stream.IntStream; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Grid; + +/** + * Test UI for Grid initial rendering performance profiling. + */ +@Widgetset("com.vaadin.DefaultWidgetSet") +public class GridManyColumns extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Grid<String> grid = new Grid<>(); + grid.setSizeFull(); + for (int i = 0; i < 80; i++) { + grid.addColumn(row -> "novalue").setCaption("Column_" + i) + .setWidth(200); + } + grid.setItems(IntStream.range(0, 10).boxed().map(i -> "")); + addComponent(grid); + } +} diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridManyColumnsV7.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridManyColumnsV7.java new file mode 100644 index 0000000000..0dc2a60887 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridManyColumnsV7.java @@ -0,0 +1,51 @@ +package com.vaadin.tests.components.grid; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.v7.data.Container.Indexed; +import com.vaadin.v7.data.Item; +import com.vaadin.v7.data.util.IndexedContainer; +import com.vaadin.v7.ui.Grid; + +/** + * Test UI for Grid initial rendering performance profiling. + */ +@Widgetset("com.vaadin.v7.Vaadin7WidgetSet") +public class GridManyColumnsV7 extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Grid grid = new Grid(); + grid.setSizeFull(); + for (int i = 0; i < 80; i++) { + grid.addColumn("Column_" + i).setWidth(200); + } + grid.setContainerDataSource(createContainer()); + addComponent(grid); + } + + private Indexed createContainer() { + Indexed container = new IndexedContainer(); + + container.addContainerProperty("foo", String.class, "foo"); + container.addContainerProperty("bar", Integer.class, 0); + // km contains double values from 0.0 to 2.0 + container.addContainerProperty("km", Double.class, 0); + for (int i = 0; i < 80; ++i) { + container.addContainerProperty("Column_" + i, String.class, + "novalue"); + } + + for (int i = 0; i <= 10; ++i) { + Object itemId = container.addItem(); + Item item = container.getItem(itemId); + for (int j = 0; j < 80; ++j) { + item.getItemProperty("Column_" + j).setValue("novalue"); + } + } + + return container; + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridManyColumnsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridManyColumnsTest.java new file mode 100644 index 0000000000..c95a01fd1d --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridManyColumnsTest.java @@ -0,0 +1,49 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.grid; + +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.testbench.parallel.TestCategory; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests that Grid gets correct height based on height mode, and resizes + * properly with details row if height is undefined. + * + * @author Vaadin Ltd + */ +@TestCategory("grid") +public class GridManyColumnsTest extends MultiBrowserTest { + + @Override + public void setup() throws Exception { + super.setup(); + openTestURL(); + waitForElementPresent(By.className("v-grid")); + } + + @Test + public void testGridPerformance() throws InterruptedException { + long renderingTime = testBench().totalTimeSpentRendering(); + long requestTime = testBench().totalTimeSpentServicingRequests(); + System.out.println("Grid with many columns spent " + renderingTime + + "ms rendering and " + requestTime + "ms servicing requests (" + + getDesiredCapabilities().getBrowserName() + ")"); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridManyColumnsV7Test.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridManyColumnsV7Test.java new file mode 100644 index 0000000000..dce96dfd43 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridManyColumnsV7Test.java @@ -0,0 +1,49 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.grid; + +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.testbench.parallel.TestCategory; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests that Grid gets correct height based on height mode, and resizes + * properly with details row if height is undefined. + * + * @author Vaadin Ltd + */ +@TestCategory("grid") +public class GridManyColumnsV7Test extends MultiBrowserTest { + + @Override + public void setup() throws Exception { + super.setup(); + openTestURL(); + waitForElementPresent(By.className("v-grid")); + } + + @Test + public void testGridPerformance() throws InterruptedException { + long renderingTime = testBench().totalTimeSpentRendering(); + long requestTime = testBench().totalTimeSpentServicingRequests(); + System.out.println("Grid V7 with many columns spent " + renderingTime + + "ms rendering and " + requestTime + "ms servicing requests (" + + getDesiredCapabilities().getBrowserName() + ")"); + } + +} |