Skip to content
Snippets Groups Projects
03-using-wrapper.scala 481 B
Newer Older
// Lecture 1 : Page 12/15
package lecture1

def countLots: Long =
  var s,i: Long = 0
  while i < 7 do
    var j: Long = 0
      while j < 900000000 do
        j = j + 1
        s = s + i + j
      i = i + 1
    //println(i)
  s

def testCounts: (Long, Long) =
  val (x, y) = (thread(countLots), thread(countLots))
  (x.joinMe, y.joinMe)

def time[A](computation: => A): (A, Long) =
  val timePre: Long = System.currentTimeMillis
  (computation, System.currentTimeMillis - timePre)