-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change makes sure that reported warnings are unique, based on the value of internal clock tick and ignoring differences in reassignments. Before: ![Screenshot from 2023-04-20 15-42-55](https://user-images.githubusercontent.com/292128/233415710-925c1045-37c7-49f5-9bc3-bfbfd30270a3.png) After: ![Screenshot from 2023-04-20 15-27-27](https://user-images.githubusercontent.com/292128/233415807-8cb67bc2-ac37-4db7-924e-ae7619074b5b.png) On the positive side, no further changes, like in LS, have to be done. Closes #6257.
- Loading branch information
Showing
28 changed files
with
406 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...time/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/WarningBenchmarks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package org.enso.interpreter.bench.benchmarks.semantic; | ||
|
||
import org.enso.interpreter.test.TestBase; | ||
import org.enso.polyglot.MethodNames; | ||
import org.graalvm.polyglot.Context; | ||
import org.graalvm.polyglot.Value; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.Measurement; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.annotations.TearDown; | ||
import org.openjdk.jmh.annotations.Warmup; | ||
import org.openjdk.jmh.infra.BenchmarkParams; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
@BenchmarkMode(Mode.AverageTime) | ||
@Fork(1) | ||
@Warmup(iterations = 5, time = 1) | ||
@Measurement(iterations = 3, time = 3) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
@State(Scope.Benchmark) | ||
public class WarningBenchmarks extends TestBase { | ||
private static final int INPUT_VEC_SIZE = 10000; | ||
private Context ctx; | ||
private Value vecSumBench; | ||
|
||
private Value createVec; | ||
private Value noWarningsVec; | ||
private Value sameWarningVec; | ||
|
||
private Value elem; | ||
|
||
private Value elemWithWarning; | ||
|
||
private String benchmarkName; | ||
|
||
@Setup | ||
public void initializeBench(BenchmarkParams params) throws IOException { | ||
ctx = createDefaultContext(); | ||
|
||
benchmarkName = params.getBenchmark().replaceFirst(".*\\.", ""); | ||
|
||
var code = """ | ||
from Standard.Base import all | ||
vec_sum_bench : Vector Integer -> Integer | ||
vec_sum_bench vec = | ||
vec.fold 0 (x->y->x+y) | ||
create_vec size elem = | ||
Vector.fill size elem | ||
elem = | ||
42 | ||
elem_with_warning = | ||
x = 42 | ||
Warning.attach "Foo!" x | ||
"""; | ||
var src = SrcUtil.source(benchmarkName, code); | ||
Value module = ctx.eval(src); | ||
vecSumBench = Objects.requireNonNull(module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "vec_sum_bench")); | ||
createVec = Objects.requireNonNull(module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "create_vec")); | ||
elem = Objects.requireNonNull(module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "elem")); | ||
elemWithWarning = Objects.requireNonNull(module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "elem_with_warning")); | ||
noWarningsVec = createVec.execute(INPUT_VEC_SIZE, elem); | ||
sameWarningVec = createVec.execute(INPUT_VEC_SIZE, elemWithWarning); | ||
} | ||
|
||
@TearDown | ||
public void cleanup() { | ||
ctx.close(true); | ||
} | ||
|
||
@Benchmark | ||
public void noWarningsVecSum() { | ||
Value res = vecSumBench.execute(noWarningsVec); | ||
checkResult(res); | ||
} | ||
|
||
@Benchmark | ||
public void sameWarningVecSum() { | ||
Value res = vecSumBench.execute(sameWarningVec); | ||
checkResult(res); | ||
} | ||
|
||
private static void checkResult(Value res) { | ||
if (res.asInt() != INPUT_VEC_SIZE*42) { | ||
throw new AssertionError("Expected result: " + INPUT_VEC_SIZE*42 + ", got: " + res.asInt()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.