mirror of
https://github.com/enso-org/enso.git
synced 2024-11-10 12:48:25 +03:00
Fix benchmarks (#3639)
This commit is contained in:
parent
98d30bccf3
commit
1083a2532e
@ -22,17 +22,17 @@ public class AtomBenchmarks {
|
||||
@Benchmark
|
||||
public void benchGenerateList() {
|
||||
DefaultInterpreterRunner.MainMethod main = fixtures.generateList();
|
||||
main.mainFunction().value().execute(main.mainConstructor(), fixtures.million());
|
||||
main.mainFunction().value().execute(fixtures.million());
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void benchGenerateListQualified() {
|
||||
DefaultInterpreterRunner.MainMethod main = fixtures.generateListQualified();
|
||||
main.mainFunction().value().execute(main.mainConstructor(), fixtures.million());
|
||||
main.mainFunction().value().execute(fixtures.million());
|
||||
}
|
||||
|
||||
private void benchOnList(DefaultInterpreterRunner.MainMethod main) {
|
||||
main.mainFunction().value().execute(main.mainConstructor(), fixtures.millionElementList());
|
||||
main.mainFunction().value().execute(fixtures.millionElementList());
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
|
@ -22,7 +22,7 @@ public class CallableBenchmarks {
|
||||
new CallableFixtures();
|
||||
|
||||
private void runOnHundredMillion(DefaultInterpreterRunner.MainMethod main) {
|
||||
main.mainFunction().value().execute(main.mainConstructor(), argumentFixtures.hundredMillion());
|
||||
main.mainFunction().value().execute(argumentFixtures.hundredMillion());
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
|
@ -21,7 +21,7 @@ public class NamedDefaultedArgumentBenchmarks {
|
||||
new NamedDefaultedArgumentFixtures();
|
||||
|
||||
private void runOnHundredMillion(DefaultInterpreterRunner.MainMethod main) {
|
||||
main.mainFunction().value().execute(main.mainConstructor(), argumentFixtures.hundredMillion());
|
||||
main.mainFunction().value().execute(argumentFixtures.hundredMillion());
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
|
@ -15,7 +15,7 @@ public class RecursionBenchmarks {
|
||||
private static RecursionFixtures recursionFixtures = new RecursionFixtures();
|
||||
|
||||
private void runOnHundredMillion(DefaultInterpreterRunner.MainMethod main) {
|
||||
main.mainFunction().value().execute(main.mainConstructor(), recursionFixtures.hundredMillion());
|
||||
main.mainFunction().value().execute(recursionFixtures.hundredMillion());
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@ -36,7 +36,7 @@ public class RecursionBenchmarks {
|
||||
@Benchmark
|
||||
public void benchSumRecursive() {
|
||||
DefaultInterpreterRunner.MainMethod main = recursionFixtures.sumRecursive();
|
||||
main.mainFunction().value().execute(main.mainConstructor(), recursionFixtures.hundred());
|
||||
main.mainFunction().value().execute(recursionFixtures.hundred());
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
|
@ -29,9 +29,9 @@ class AtomFixtures extends DefaultInterpreterRunner {
|
||||
"""from Standard.Base.Data.List import all
|
||||
|
|
||||
|main = length ->
|
||||
| generator = acc -> i -> if i == 0 then acc else @Tail_Call generator (List.cons i acc) (i - 1)
|
||||
| generator = acc -> i -> if i == 0 then acc else @Tail_Call generator (List.Cons i acc) (i - 1)
|
||||
|
|
||||
| res = generator List.nil length
|
||||
| res = generator List.Nil length
|
||||
| res
|
||||
""".stripMargin
|
||||
val generateListQualified = getMain(generateListQualifiedCode)
|
||||
@ -52,10 +52,10 @@ class AtomFixtures extends DefaultInterpreterRunner {
|
||||
val reverseListMethodsCode =
|
||||
"""from Standard.Base.Data.List import all
|
||||
|
|
||||
|Cons.rev = acc -> case self of
|
||||
|Cons.rev self = acc -> case self of
|
||||
| Cons h t -> @Tail_Call t.rev (Cons h acc)
|
||||
|
|
||||
|Nil.rev = acc -> acc
|
||||
|Nil.rev self = acc -> acc
|
||||
|
|
||||
|main = list ->
|
||||
| res = list.rev Nil
|
||||
@ -105,8 +105,8 @@ class AtomFixtures extends DefaultInterpreterRunner {
|
||||
val sumListMethodsCode =
|
||||
"""from Standard.Base.Data.List import all
|
||||
|
|
||||
|Nil.sum = acc -> acc
|
||||
|Cons.sum = acc -> case self of
|
||||
|Nil.sum self = acc -> acc
|
||||
|Cons.sum self = acc -> case self of
|
||||
| Cons h t -> @Tail_Call t.sum h+acc
|
||||
|
|
||||
|main = list ->
|
||||
@ -118,8 +118,8 @@ class AtomFixtures extends DefaultInterpreterRunner {
|
||||
val mapReverseListCode =
|
||||
"""from Standard.Base.Data.List import all
|
||||
|
|
||||
|Nil.mapReverse = f -> acc -> acc
|
||||
|Cons.mapReverse = f -> acc -> case self of
|
||||
|Nil.mapReverse self = f -> acc -> acc
|
||||
|Cons.mapReverse self = f -> acc -> case self of
|
||||
| Cons h t -> @Tail_Call t.mapReverse f (Cons (f h) acc)
|
||||
|
|
||||
|main = list ->
|
||||
@ -131,8 +131,8 @@ class AtomFixtures extends DefaultInterpreterRunner {
|
||||
val mapReverseListCurryCode =
|
||||
"""from Standard.Base.Data.List import all
|
||||
|
|
||||
|Nil.mapReverse = f -> acc -> acc
|
||||
|Cons.mapReverse = f -> acc -> case self of
|
||||
|Nil.mapReverse self = f -> acc -> acc
|
||||
|Cons.mapReverse self = f -> acc -> case self of
|
||||
| Cons h t -> @Tail_Call t.mapReverse f (Cons (f h) acc)
|
||||
|
|
||||
|main = list ->
|
||||
|
@ -24,10 +24,10 @@ class CallableFixtures extends DefaultInterpreterRunner {
|
||||
val sumTCOmethodCallCode =
|
||||
"""
|
||||
|summator = acc -> current ->
|
||||
| if current == 0 then acc else @Tail_Call here.summator (acc + current) (current - 1)
|
||||
| if current == 0 then acc else @Tail_Call summator (acc + current) (current - 1)
|
||||
|
|
||||
|main = sumTo ->
|
||||
| res = here.summator 0 sumTo
|
||||
| res = summator 0 sumTo
|
||||
| res
|
||||
|""".stripMargin
|
||||
val sumTCOmethodCall = getMain(sumTCOmethodCallCode)
|
||||
@ -35,10 +35,10 @@ class CallableFixtures extends DefaultInterpreterRunner {
|
||||
val sumTCOmethodCallWithNamedArgumentsCode =
|
||||
"""
|
||||
|summator = acc -> current ->
|
||||
| if current == 0 then acc else @Tail_Call here.summator (current = current - 1) (acc = acc + current)
|
||||
| if current == 0 then acc else @Tail_Call summator (current = current - 1) (acc = acc + current)
|
||||
|
|
||||
|main = sumTo ->
|
||||
| res = here.summator current=sumTo acc=0
|
||||
| res = summator current=sumTo acc=0
|
||||
| res
|
||||
|""".stripMargin
|
||||
val sumTCOmethodCallWithNamedArguments =
|
||||
@ -47,10 +47,10 @@ class CallableFixtures extends DefaultInterpreterRunner {
|
||||
val sumTCOmethodCallWithDefaultedArgumentsCode =
|
||||
"""
|
||||
|summator = (acc = 0) -> current ->
|
||||
| if current == 0 then acc else @Tail_Call here.summator (current = current - 1) (acc = acc + current)
|
||||
| if current == 0 then acc else @Tail_Call summator (current = current - 1) (acc = acc + current)
|
||||
|
|
||||
|main = sumTo ->
|
||||
| res = here.summator current=sumTo
|
||||
| res = summator current=sumTo
|
||||
| res
|
||||
|""".stripMargin
|
||||
val sumTCOmethodCallWithDefaultedArguments =
|
||||
|
@ -156,10 +156,10 @@ trait InterpreterRunner {
|
||||
instrumenter.close()
|
||||
}
|
||||
|
||||
case class MainMethod(mainConstructor: Value, mainFunction: Function) {
|
||||
case class MainMethod(mainFunction: Function) {
|
||||
def execute(args: AnyRef*): Value =
|
||||
InterpreterException.rethrowPolyglot(
|
||||
mainFunction.execute(mainConstructor +: args: _*)
|
||||
mainFunction.execute(args: _*)
|
||||
)
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ trait InterpreterRunner {
|
||||
)
|
||||
val assocCons = module.getAssociatedConstructor
|
||||
val mainFunction = module.getMethod(assocCons, "main").get
|
||||
MainMethod(assocCons, mainFunction)
|
||||
MainMethod(mainFunction)
|
||||
}
|
||||
|
||||
def eval(
|
||||
|
Loading…
Reference in New Issue
Block a user