Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2017-05-06 10:16:17 -0400
committerThomas Wolf2017-05-06 10:41:01 -0400
commit9ee41054835597f90a17cb2bc9c15123b586af65 (patch)
tree80ba83dfba7458dc963c21c81eba720956355fb1 /org.eclipse.egit.core.test/src
parentcbabb739a718f570244a06c585c29cd85beca660 (diff)
downloadegit-9ee41054835597f90a17cb2bc9c15123b586af65.tar.gz
egit-9ee41054835597f90a17cb2bc9c15123b586af65.tar.xz
egit-9ee41054835597f90a17cb2bc9c15123b586af65.zip
Throttle updates of the EclipseGitProgressTransformer
This progress monitor updated its SubMonitor every time if total == UNKNOWN. This can be very inefficient since it may involve a UI update. Oxygen seems to include a progress monitor that optimizes for this, but on Neon and earlier Eclipses, this progress reporting may slow down operations. Most noticeably it occurred in the "counting objects" phase of a push operation, which would become unuseably slow if run in the foreground, but which would terminate quickly when run in the background. Bug: 516276 Change-Id: Ib3e37918f493da6a04eb51bcc7086ecd3eb2bc6f Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.core.test/src')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/EclipseGitProgressTransformerTest.java30
1 files changed, 29 insertions, 1 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/EclipseGitProgressTransformerTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/EclipseGitProgressTransformerTest.java
index 50f47b2f2..1ffbc4a90 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/EclipseGitProgressTransformerTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/EclipseGitProgressTransformerTest.java
@@ -8,6 +8,8 @@
*******************************************************************************/
package org.eclipse.egit.core.test;
+import java.util.concurrent.TimeUnit;
+
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.egit.core.EclipseGitProgressTransformer;
import org.eclipse.jgit.lib.ProgressMonitor;
@@ -32,7 +34,7 @@ public class EclipseGitProgressTransformerTest {
}
@Test
- public void testUnboundedMonitor() {
+ public void testUnboundedMonitor() throws InterruptedException {
final String title = "Title";
classUnderTest.beginTask(title, ProgressMonitor.UNKNOWN);
@@ -41,12 +43,38 @@ public class EclipseGitProgressTransformerTest {
classUnderTest.update(10);
classUnderTest.update(0);
Mockito.verify(eclipseMonitor, Mockito.times(1)).subTask("Title, 10");
+ // If updated too quickly, the EclipseGitProgressTransformar may skip
+ // updates for performance reasons.
+ Thread.sleep(TimeUnit.SECONDS.toMillis(1));
classUnderTest.update(20);
Mockito.verify(eclipseMonitor).subTask("Title, 30");
}
@Test
+ public void testUnboundedMonitorFastUpdate() throws InterruptedException {
+ final String title = "Title";
+
+ classUnderTest.beginTask(title, ProgressMonitor.UNKNOWN);
+ Mockito.verify(eclipseMonitor).subTask("Title");
+
+ classUnderTest.update(10);
+ classUnderTest.update(0);
+ Mockito.verify(eclipseMonitor, Mockito.times(1)).subTask("Title, 10");
+ for (int i = 0; i < 10; i++) {
+ classUnderTest.update(10);
+ }
+ // If updated too quickly, the EclipseGitProgressTransformar may skip
+ // updates for performance reasons. But even then the final count
+ // when an update has occurred should include intermediary updates
+ // that were not reported in the UI.
+ Thread.sleep(TimeUnit.SECONDS.toMillis(1));
+ classUnderTest.update(20);
+ Mockito.verify(eclipseMonitor).subTask("Title, 130");
+
+ }
+
+ @Test
public void testBoundedMonitor() {
final String title = "Title";

Back to the top