spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From witgo <...@git.apache.org>
Subject [GitHub] spark pull request: SPARK-1470: Spark logger moving to use scala-l...
Date Wed, 16 Apr 2014 17:17:42 GMT
Github user witgo commented on the pull request:

    https://github.com/apache/spark/pull/332#issuecomment-40626222
  
    I don't think macros is faster than the inline method
    ```scala
    import scala.compat.Platform
    
    class Log(val flag: Boolean) {
    
      def logFunction0(msg: => String) {
        if (flag)
          println(msg)
      }
    
      def logString(msg: String) {
        if (flag)
          println(msg)
      }
    
      @inline
      def logInline(msg: => String) {
        if (flag)
          println(msg)
      }
    }
    
    val log = new Log(false)
    var startTime = Platform.currentTime
    var i = 0
    while (i < 1000000) {
      log.logInline("" + Thread.currentThread.getStackTrace().
        toSeq.take(10).mkString("\\n"))
      i += 1
    }
    var stopTime = Platform.currentTime
    Platform.collectGarbage
    println("logInline: " + (stopTime - startTime) + " ms")
    
    startTime = Platform.currentTime
    i = 0
    while (i < 1000000) {
      log.logFunction0("" + Thread.currentThread.getStackTrace().
        toSeq.take(10).mkString("\\n"))
      i += 1
    }
    stopTime = Platform.currentTime
    Platform.collectGarbage
    println("logFunction0: " + (stopTime - startTime) + " ms")
    
    startTime = Platform.currentTime
    i = 0
    while (i < 1000000) {
      log.logString("" + Thread.currentThread.getStackTrace().
        toSeq.take(10).mkString("\\n"))
      i += 1
    }
    stopTime = Platform.currentTime
    Platform.collectGarbage
    println("logString: " + (stopTime - startTime) + " ms")
    ````
        
    =>
    
    1.
    
    	logInline: 9 ms
    	logFunction0: 14 ms
    	logString: 29114 ms
    
    2.
    
    	logInline: 10 ms
    	logFunction0: 13 ms
    	logString: 28876 ms
    3.
    
    	logInline: 9 ms
    	logFunction0: 13 ms
    	logString: 28521 ms


---
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.
---

Mime
View raw message