How to measure the execution time of a query on Spark

后端 未结 5 1330
误落风尘
误落风尘 2020-12-01 19:16

I need to measure the execution time of query on Apache spark (Bluemix). What I tried:

import time

startTimeQuery = time.clock()
df = sqlContext.sql(query)
         


        
5条回答
  •  醉酒成梦
    2020-12-01 19:37

    I use System.nanoTime wrapped around a helper function, like this -

    def time[A](f: => A) = {
      val s = System.nanoTime
      val ret = f
      println("time: "+(System.nanoTime-s)/1e6+"ms")
      ret
    }
    
    time {
      df = sqlContext.sql(query)
      df.show()
    }
    

提交回复
热议问题