skip to main | skip to sidebar

this.getClass()

Thursday, September 27, 2012

Meassure Execution Time

  def meassureExecutionTime(block: => Unit) = {
    val start = System.currentTimeMillis();
    block
    val end = System.currentTimeMillis();
    end - start;
  }

  var sum = 0;
  val time = meassureExecutionTime {
    for (i <- 1 to 100000) {
      sum += i;
    }
  }
  println(sum);

  println(time);
Posted by tkr at 5:48 AM
Labels: Scala

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Labels

  • Scala
  • DSL
  • AspectJ
  • Groovy
  • Java

Blog Archive

  • ▼  2012 (25)
    • ▼  September (25)
      • Structural Typing Zur Hilfe
      • Structural Food Typing
      • Pattern Matching Unpack
      • Pattern Matching Simplify
      • Pattern Matching Case Classes
      • Pattern Matching Cal
      • Pattern Matching Beverages
      • Pattern Matching Basics
      • Duck Typing
      • Case Classes
      • Closures
      • Schedule
      • Meassure Execution Time
      • Filter and Map
      • Brainteaser
      • Twice
      • Group By Task
      • Call with Retry
      • Syntactic Sugar
      • Functions, Params and Return
      • GroupBy, ForEach and Case
      • Reduce, Min, MinBy, Sum and MkString
      • Type Inference and Generics
      • Classes and Methods
      • Vals, Vars, Attributes and Contructors
  • ►  2008 (9)
    • ►  December (1)
    • ►  May (1)
    • ►  March (3)
    • ►  February (4)