equal
deleted
inserted
replaced
6 |
6 |
7 type Mem = Map[Int, Int] |
7 type Mem = Map[Int, Int] |
8 |
8 |
9 |
9 |
10 // (1) Write a function that takes a file name as argument and |
10 // (1) Write a function that takes a file name as argument and |
11 // and requests the corresponding file from disk. It returns the |
11 // and requests the corresponding file from disk. It Returns the |
12 // content of the file as a String. If the file does not exists, |
12 // content of the file as a String. If the file does not exists, |
13 // the function should return the empty string. |
13 // the function should Return the empty string. |
14 |
14 |
15 import io.Source |
15 import io.Source |
16 import scala.util._ |
16 import scala.util._ |
17 |
17 |
18 //def load_bff(name: String) : String = ... |
18 //def load_bff(name: String) : String = ... |
184 |
184 |
185 def time_needed[T](n: Int, code: => T) = { |
185 def time_needed[T](n: Int, code: => T) = { |
186 val start = System.nanoTime() |
186 val start = System.nanoTime() |
187 for (i <- 0 until n) code |
187 for (i <- 0 until n) code |
188 val end = System.nanoTime() |
188 val end = System.nanoTime() |
189 (end - start)/1.0e9 |
189 (end - start)/(n * 1.0e9) |
190 } |
190 } |
191 |
191 |
192 time_needed(1, run(b1)) |
192 time_needed(1, run(b1)) |
193 */ |
193 */ |
194 |
194 |