aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/test/java')
-rw-r--r--core/src/test/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorterSuite.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/core/src/test/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorterSuite.java b/core/src/test/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorterSuite.java
index 60a40cc172..2cae4beb4c 100644
--- a/core/src/test/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorterSuite.java
+++ b/core/src/test/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorterSuite.java
@@ -49,6 +49,7 @@ import org.apache.spark.storage.*;
import org.apache.spark.unsafe.Platform;
import org.apache.spark.util.Utils;
+import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.junit.Assert.*;
import static org.mockito.Answers.RETURNS_SMART_NULLS;
@@ -226,6 +227,25 @@ public class UnsafeExternalSorterSuite {
}
@Test
+ public void testSortTimeMetric() throws Exception {
+ final UnsafeExternalSorter sorter = newSorter();
+ long prevSortTime = sorter.getSortTimeNanos();
+ assertEquals(prevSortTime, 0);
+
+ sorter.insertRecord(null, 0, 0, 0);
+ sorter.spill();
+ assertThat(sorter.getSortTimeNanos(), greaterThan(prevSortTime));
+ prevSortTime = sorter.getSortTimeNanos();
+
+ sorter.spill(); // no sort needed
+ assertEquals(sorter.getSortTimeNanos(), prevSortTime);
+
+ sorter.insertRecord(null, 0, 0, 0);
+ UnsafeSorterIterator iter = sorter.getSortedIterator();
+ assertThat(sorter.getSortTimeNanos(), greaterThan(prevSortTime));
+ }
+
+ @Test
public void spillingOccursInResponseToMemoryPressure() throws Exception {
final UnsafeExternalSorter sorter = newSorter();
// This should be enough records to completely fill up a data page: