Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11018#discussion_r51528424
  
    --- Diff: core/src/main/scala/org/apache/spark/util/Benchmark.scala ---
    @@ -99,22 +99,25 @@ private[spark] object Benchmark {
        * the rate of the function.
        */
       def measure(num: Long, iters: Int, outputPerIteration: Boolean)(f: Int 
=> Unit): Result = {
    -    var totalTime = 0L
    +    var bestTime = Long.MaxValue
         for (i <- 0 until iters + 1) {
           val start = System.nanoTime()
     
           f(i)
     
           val end = System.nanoTime()
    -      if (i != 0) totalTime += end - start
    +      val runTime = end - start
    +      if (runTime < bestTime) {
    +        bestTime = runTime
    +      }
     
           if (outputPerIteration) {
             // scalastyle:off
    -        println(s"Iteration $i took ${(end - start) / 1000} microseconds")
    +        println(s"Iteration $i took ${runTime / 1000} microseconds")
             // scalastyle:on
           }
         }
    -    Result(totalTime.toDouble / 1000000 / iters, num * iters / 
(totalTime.toDouble / 1000))
    +    Result(bestTime.toDouble / 1000000, num / (bestTime.toDouble / 1000))
    --- End diff --
    
    as discussed offline, I don't think this is a good idea. at the very least 
if you want to compare best time, you should also report avg time, which is a 
more reasonable number to compare.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to