File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
scala/src/test/scala/ch11_sorts Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -47,15 +47,15 @@ class SortsTest extends FlatSpec with Matchers {
4747 array(i) = rnd.nextInt()
4848 }
4949
50- timed(" bubbleSort" , Sorts .bubbleSort( array.clone() ))
51- timed(" insertSort" , Sorts .bubbleSort( array.clone() ))
52- timed(" selectionSort" , Sorts .bubbleSort( array.clone() ))
50+ timed(" bubbleSort" , Sorts .bubbleSort, array.clone())
51+ timed(" insertSort" , Sorts .insertSort, array.clone())
52+ timed(" selectionSort" , Sorts .selectionSort, array.clone())
5353 }
5454
5555 def reportElapsed (name : String , time : Long ): Unit = println(name + " takes in " + time + " ms" )
5656
57- def timed [T ](name : String , f : => T ): T = {
57+ def timed [T ](name : String , f : ( Array [ Int ]) => T , array : Array [ Int ] ): T = {
5858 val start = System .currentTimeMillis()
59- try f finally reportElapsed(name, System .currentTimeMillis - start)
59+ try f(array) finally reportElapsed(name, System .currentTimeMillis - start)
6060 }
6161}
You can’t perform that action at this time.
0 commit comments