-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Stops creating a constant pool key eagerly as it was being created 11 times for a simple click listener after each event data expression was evaluated. The change improves the server side roundtrip processing time for 2000 buttons with click listeners from roughly 210ms to 130ms (-40%) by not eagerly creating the id using MessageDigest after evaluating each event data expression. Difference to buttons without any click listeners is still about x2 (65ms->130ms). Next step is to also make it not create the MessageDigest over and over again. Part of #7826 Co-authored-by: Pekka Hyvönen <[email protected]>
- Loading branch information
1 parent
a549e84
commit 47407bf
Showing
5 changed files
with
98 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...est-root-context/src/main/java/com/vaadin/flow/uitest/ui/ConstantPoolPerformanceView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2000-2021 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.flow.uitest.ui; | ||
|
||
import com.vaadin.flow.component.html.Div; | ||
import com.vaadin.flow.component.html.NativeButton; | ||
import com.vaadin.flow.router.Route; | ||
|
||
/* Manual test case for #7826 */ | ||
@Route("performance/constant-pool") | ||
public class ConstantPoolPerformanceView extends AbstractDivView { | ||
|
||
Div container = new Div(); | ||
Div notification = new Div(); | ||
|
||
public ConstantPoolPerformanceView() { | ||
NativeButton btn = new NativeButton( | ||
"add 2k divs without click listener"); | ||
btn.addClickListener(e -> { | ||
container.removeAll(); | ||
for (int i = 0; i < 2000; i++) { | ||
container.add(new NativeButton("No click listener ")); | ||
} | ||
}); | ||
NativeButton btn2 = new NativeButton("add 2k divs with click listener"); | ||
btn2.addClickListener(e -> { | ||
container.removeAll(); | ||
for (int i = 0; i < 2000; i++) { | ||
container.add(new NativeButton("With click listener " + i, | ||
e2 -> notification.setText("clicked"))); | ||
} | ||
}); | ||
final NativeButton clearButtons = new NativeButton("clear buttons", | ||
e -> container.removeAll()); | ||
add(btn, btn2, clearButtons, notification, container); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters