def test(collectionSize: Int) {
println("\"List (size " + collectionSize + "), test results:\"\n")
import scalqa.Stream.Enable._
class Foo(val id: Int) { def even = id % 2 == 0 }
class Bar(val foo: Foo)
val list: List[Bar] = (1 to collectionSize).map(i =>new Bar(new Foo(i))).toList
scalqa.Util.Benchmark(
("List ", () => list .filter(_.foo.even).flatMap(_ => list).map(_.foo).count(_.even)),
("List as Stream", () => list.all.filter(_.foo.even).flatMap(_ => list).map(_.foo).count(_.even)))
}
Results to Expect
"List (size 10), test results:"
Num Name Ops/Sec % Memory % Control Value Avg
--- -------------- ------- --- ------ --- -----------------
1List545.6k 352.5k 100252List as Stream 1.5m 1003171225"List (size 100), test results:"
Num Name Ops/Sec % Memory % Control Value Avg
--- -------------- ------- --- ------ --- -----------------
1List3.8k 7224.2k 10025002List as Stream 48.8k 10058602500"List (size 1000), test results:"
Num Name Ops/Sec % Memory % Control Value Avg
--- -------------- ------- --- ------ --- -----------------
1List33818.5m 1002500002List as Stream 38010000250000
"List (size 10), specialized test results:"
Num Name Ops/Sec % Memory % Control Value Av
--- -------------- ------- --- ------ - ----------------
1List471.7k 47001252List as Stream 997.2k 10000125"List (size 100), specialized test results:"
Num Name Ops/Sec % Memory % Control Value
--- -------------- ------- --- ------ --- --------------
1List4.7k 1717.5k 591250002List as Stream 27.5k 10029.5k 100125000"List (size 1000), specialized test results:"
Num Name Ops/Sec % Memory % Control Value
--- -------------- ------- --- ------ --- --------------
1List371425.8m 1001250000002List as Stream 25310036.8k 0125000000
Code to Run
Results to Expect
Specialized Test
Code to Run
Results to Expect