LuciferYang commented on code in PR #13144:
URL: https://github.com/apache/gluten/pull/13144#discussion_r4111201269


##########
gluten-core/src/test/scala/org/apache/gluten/iterator/IteratorSuite.scala:
##########
@@ -39,6 +39,25 @@ abstract class IteratorSuite extends AnyFunSuite {
     }
   }
 
+  test("Read time accumulation does not lose sub-millisecond reads") {
+    var totalMillis = 0L
+    val elementCount = 300000
+    val itr = Array.range(0, elementCount).iterator
+    val wrapped = wrap(itr)
+      .collectReadMillis(millis => totalMillis += millis)
+      .create()
+    var consumed = 0
+    while (wrapped.hasNext) {
+      wrapped.next()
+      consumed += 1
+    }
+    assert(consumed == elementCount)
+    // Each individual read takes well under a millisecond; converting per call
+    // used to truncate every duration to zero. The accumulated total over
+    // elementCount reads must be positive.
+    assert(totalMillis > 0L)

Review Comment:
   Done in 5c705e887. Extracted the accumulation into a package-visible 
`NanosToMillisAccumulator` and replaced the timing-dependent test with a 
deterministic one that feeds exact nanosecond durations: three 0.4ms adds 
report one whole millisecond only when the running total crosses 1ms, and a 
following 0.9ms add (0.2ms remainder + 0.9ms) reports the next one. Per-call 
truncation would have reported zero for every one of those adds, so the test 
now actually exercises the carry-over rather than relying on wall-clock timing.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to