| 1 |
/* |
| 2 |
* Copyright (c) 2021 Goldman Sachs. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* and Eclipse Distribution License v. 1.0 which accompany this distribution. |
| 6 |
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* and the Eclipse Distribution License is available at |
| 8 |
* http://www.eclipse.org/org/documents/edl-v10.php. |
| 9 |
*/ |
| 10 |
|
| 11 |
package org.eclipse.collections.impl.jmh |
| 12 |
|
| 13 |
import org.junit.Assert |
| 14 |
|
| 15 |
import scala.collection.mutable.ArrayBuffer |
| 16 |
|
| 17 |
object CollectScalaTest |
| 18 |
{ |
| 19 |
private val SIZE = 1000000 |
| 20 |
private val integers = new ArrayBuffer[Int](SIZE) ++ (1 to SIZE) |
| 21 |
|
| 22 |
def serial_eager_scala() |
| 23 |
{ |
| 24 |
val strings = this.integers.map(_.toString) |
| 25 |
Assert.assertEquals(SIZE, strings.size) |
| 26 |
} |
| 27 |
|
| 28 |
def serial_lazy_scala() |
| 29 |
{ |
| 30 |
val strings = this.integers.view.map(_.toString).toBuffer |
| 31 |
Assert.assertEquals(SIZE, strings.size) |
| 32 |
} |
| 33 |
|
| 34 |
def parallel_lazy_scala() |
| 35 |
{ |
| 36 |
val strings = this.integers.par.map(_.toString) |
| 37 |
Assert.assertEquals(SIZE, strings.size) |
| 38 |
} |
| 39 |
|
| 40 |
} |