spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rxin <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-13131] [SQL] Use best time in benchmark
Date Tue, 02 Feb 2016 06:17:04 GMT
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message