File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
sql/core/src/main/scala/org/apache/spark/sql Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -618,6 +618,22 @@ class SparkSession private(
618618 @ InterfaceStability .Evolving
619619 def readStream : DataStreamReader = new DataStreamReader (self)
620620
621+ /**
622+ * Executes some code block and prints to stdout the time taken to execute the block. This is
623+ * available in Scala only and is used primarily for interactive testing and debugging.
624+ *
625+ * @since 2.1.0
626+ */
627+ @ InterfaceStability .Stable
628+ def time [T ](f : => T ): T = {
629+ val start = System .nanoTime()
630+ val ret = f
631+ val end = System .nanoTime()
632+ // scalastyle:off println
633+ println(s " Time taken: ${(end - start) / 1000 / 1000 } ms " )
634+ // scalastyle:on println
635+ ret
636+ }
621637
622638 // scalastyle:off
623639 // Disable style checker so "implicits" object can start with lowercase i
You can’t perform that action at this time.
0 commit comments