Skip to content

Commit

Permalink
Stricter time verification for quick constant time operations eclipse…
Browse files Browse the repository at this point in the history
…-platform#882

As assertion now works with a time require for a single operation, we can't assume that non-constant operation will not fit in 100 ns window.
  • Loading branch information
basilevs authored Nov 13, 2023
1 parent a7a0685 commit fbdd86b
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ private void assertConstant(String message, IntFunction<Double> function) {
double elapsed_100000 = function.apply(100000);
double ratio = elapsed_100000 / elapsed_100;
String error = String.format( "%s should be constant. But:\nTime for 100 elements: %f ns\nTime for 100000 elements: %f ns\nRatio: %f\n", message, elapsed_100, elapsed_100000, ratio);
assertTrue(error, (elapsed_100000 <= 100 && elapsed_100 <= 100) || ratio < 10);
assertTrue(error, (elapsed_100000 <= 10 && elapsed_100 <= 10) || ratio < 10);
}

private void assertLinear(String message, IntFunction<Double> function) {
Expand Down

0 comments on commit fbdd86b

Please sign in to comment.