Add a benchmark for lambda performance (#81)

This commit is contained in:
Marcin Kostrzewa 2019-08-09 16:33:29 +02:00 committed by Ara Adkins
parent fec74a8925
commit caf8808ff7
2 changed files with 16 additions and 0 deletions

View File

@ -17,4 +17,9 @@ public class RecursionBenchmarks {
public void benchSumTCO() {
recursionFixtures.sumTCO().execute(recursionFixtures.hundredMillion());
}
@Benchmark
public void benchSumTCOFoldLike() {
recursionFixtures.sumTCOFoldLike().execute(recursionFixtures.hundredMillion());
}
}

View File

@ -29,6 +29,17 @@ class RecursionFixtures extends LanguageRunner {
val sumTCO = ctx.eval(Constants.LANGUAGE_ID, sumTCOCode)
val sumTCOFoldLikeCode =
"""
|{ |sumTo|
| summator = { |acc, i, f| ifZero: [i, acc, @summator [@f [acc, i], i - 1, f]] };
| res = @summator [0, sumTo, {|x, y| x + y }];
| res
|}
|""".stripMargin
val sumTCOFoldLike = eval(sumTCOFoldLikeCode)
val sumRecursiveCode =
"""
|{ |sumTo|