Debian Codegraph @

jmh-scala-tests/src/main/scala/org/eclipse/collections/impl/jmh/AnySatisfyScalaTest.scala

raw
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 AnySatisfyScalaTest
18 {
19 private val SIZE = 1000000
20 private val integers = new ArrayBuffer[Int](SIZE) ++ (1 to SIZE)
21
22 def short_circuit_middle_serial_eager_scala
23 {
24 Assert.assertTrue(this.integers.exists(_ > SIZE / 2))
25 }
26
27 def process_all_serial_eager_scala
28 {
29 Assert.assertFalse(this.integers.exists(_ < 0))
30 }
31
32 def short_circuit_middle_serial_lazy_scala
33 {
34 Assert.assertTrue(this.integers.view.exists(_ > SIZE / 2))
35 }
36
37 def process_all_serial_lazy_scala
38 {
39 Assert.assertFalse(this.integers.view.exists(_ < 0))
40 }
41
42 def short_circuit_middle_parallel_lazy_scala
43 {
44 Assert.assertTrue(this.integers.par.exists(_ == SIZE / 2 - 1))
45 }
46
47 def process_all_parallel_lazy_scala
48 {
49 Assert.assertFalse(this.integers.par.exists(_ < 0))
50 }
51 }