Skip to content

Commit 5654813

Browse files
committed
Modifications to FutureBenchmark, for performance
1 parent cd466de commit 5654813

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

test/benchmarks/src/main/scala/scala/concurrent/FutureBenchmark.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import scala.annotation.tailrec
1212
@OutputTimeUnit(TimeUnit.MILLISECONDS)
1313
@Warmup(iterations = 1000)
1414
@Measurement(iterations = 10000)
15-
@Fork(value = 1, jvmArgsAppend = Array("-Xmx1G", "-Xms1G", "-ea", "-server", "-XX:+UseCompressedOops", "-XX:+AlwaysPreTouch", "-XX:+UseCondCardMark"))
15+
@Fork(value = 1, jvmArgsAppend = Array("-Xmx1G", "-Xms1G", "-server", "-XX:+AggressiveOpts", "-XX:+UseCompressedOops", "-XX:+AlwaysPreTouch", "-XX:+UseCondCardMark"))
1616
@Threads(value = 1)
1717
abstract class AbstractBaseFutureBenchmark {
1818
// fjp = ForkJoinPool, fix = FixedThreadPool, fie = FutureInternalExecutor, gbl = GlobalEC
@@ -262,12 +262,12 @@ class AndThenFutureBenchmark extends OpFutureBenchmark {
262262
}
263263

264264
class VariousFutureBenchmark extends OpFutureBenchmark {
265-
final val mapFun: Result => Result = _.toUpperCase
266-
final val flatMapFun: Result => Future[Result] = r => Future.successful(r)
267-
final val filterFun: Result => Boolean = _ ne null
268-
final val transformFun: Try[Result] => Try[Result] = _ => throw null
269-
final val recoverFun: PartialFunction[Throwable, Result] = { case _ => "OK" }
270-
final val keepLeft: (Result, Result) => Result = (a,b) => a
265+
private[this] final val mapFun: Result => Result = _.toUpperCase
266+
private[this] final val flatMapFun: Result => Future[Result] = r => Future.successful(r)
267+
private[this] final val filterFun: Result => Boolean = _ ne null
268+
private[this] final val transformFun: Try[Result] => Try[Result] = _ => throw null
269+
private[this] final val recoverFun: PartialFunction[Throwable, Result] = { case _ => "OK" }
270+
private[this] final val keepLeft: (Result, Result) => Result = (a,b) => a
271271

272272
@tailrec private[this] final def next(i: Int, f: Future[Result])(implicit ec: ExecutionContext): Future[Result] =
273273
if (i > 0) { next(i - 1, f.map(mapFun).flatMap(flatMapFun).filter(filterFun).zipWith(f)(keepLeft).transform(transformFun).recover(recoverFun)) } else { f }
@@ -284,8 +284,8 @@ class VariousFutureBenchmark extends OpFutureBenchmark {
284284
}
285285

286286
class LoopFutureBenchmark extends OpFutureBenchmark {
287-
val depth = 50
288-
val size = 2000
287+
private[this] val depth = 50
288+
private[this] val size = 2000
289289

290290
final def pre_loop(i: Int)(implicit ec: ExecutionContext): Future[Int] =
291291
if (i % depth == 0) Future.successful(i + 1).flatMap(pre_loop)

0 commit comments

Comments
 (0)