Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(currentResult, baselineResult, percentChange, isRegression, isImprovement, isFirstRun);
}
/** {@return the builder} */

public static Builder builder() {
return new Builder();
Expand All @@ -141,41 +142,84 @@ public static class Builder {
private boolean isImprovement;
private boolean isFirstRun;
private double thresholdPercent;
/**
* Current result.
*
* @param currentResult the current result
* @return the current result
*/

public Builder currentResult(BenchmarkResult currentResult) {
this.currentResult = currentResult;
return this;
}
/**
* Baseline result.
*
* @param baselineResult the baseline result
* @return the baseline result
*/

public Builder baselineResult(BenchmarkResult baselineResult) {
this.baselineResult = baselineResult;
return this;
}
/**
* Percent change.
*
* @param percentChange the percent change
* @return the percent change
*/

public Builder percentChange(double percentChange) {
this.percentChange = percentChange;
return this;
}
/**
* Is regression.
*
* @param isRegression the is regression
* @return the is regression
*/

public Builder isRegression(boolean isRegression) {
this.isRegression = isRegression;
return this;
}
/**
* Is improvement.
*
* @param isImprovement the is improvement
* @return the is improvement
*/

public Builder isImprovement(boolean isImprovement) {
this.isImprovement = isImprovement;
return this;
}
/**
* Is first run.
*
* @param isFirstRun the is first run
* @return the is first run
*/

public Builder isFirstRun(boolean isFirstRun) {
this.isFirstRun = isFirstRun;
return this;
}
/**
* Threshold percent.
*
* @param thresholdPercent the threshold percent
* @return the threshold percent
*/

public Builder thresholdPercent(double thresholdPercent) {
this.thresholdPercent = thresholdPercent;
return this;
}
/** {@return the build} */

public BenchmarkComparisonResult build() {
return new BenchmarkComparisonResult(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(testClass, testMethod, timestamp);
}
/** {@return the builder} */

public static Builder builder() {
return new Builder();
Expand All @@ -176,56 +177,117 @@ public static class Builder {
private long minTimePerInvocationNanos;
private long maxTimePerInvocationNanos;
private List<Long> invocationTimesNanos = new ArrayList<>();
/**
* Test class.
*
* @param testClass the test class
* @return the test class
*/

public Builder testClass(String testClass) {
this.testClass = testClass;
return this;
}
/**
* Test method.
*
* @param testMethod the test method
* @return the test method
*/

public Builder testMethod(String testMethod) {
this.testMethod = testMethod;
return this;
}
/**
* Timestamp.
*
* @param timestamp the timestamp
* @return the timestamp
*/

public Builder timestamp(LocalDateTime timestamp) {
this.timestamp = timestamp;
return this;
}
/**
* Threads.
*
* @param threads the threads
* @return the threads
*/

public Builder threads(int threads) {
this.threads = threads;
return this;
}
/**
* Invocations.
*
* @param invocations the invocations
* @return the invocations
*/

public Builder invocations(int invocations) {
this.invocations = invocations;
return this;
}
/**
* Total execution time in nanoseconds.
*
* @param totalExecutionTimeNanos the total execution time in nanoseconds
* @return the total execution time in nanoseconds
*/

public Builder totalExecutionTimeNanos(long totalExecutionTimeNanos) {
this.totalExecutionTimeNanos = totalExecutionTimeNanos;
return this;
}
/**
* Avg time per invocation in nanoseconds.
*
* @param avgTimePerInvocationNanos the avg time per invocation in nanoseconds
* @return the avg time per invocation in nanoseconds
*/

public Builder avgTimePerInvocationNanos(long avgTimePerInvocationNanos) {
this.avgTimePerInvocationNanos = avgTimePerInvocationNanos;
return this;
}
/**
* Min time per invocation in nanoseconds.
*
* @param minTimePerInvocationNanos the min time per invocation in nanoseconds
* @return the min time per invocation in nanoseconds
*/

public Builder minTimePerInvocationNanos(long minTimePerInvocationNanos) {
this.minTimePerInvocationNanos = minTimePerInvocationNanos;
return this;
}
/**
* Max time per invocation in nanoseconds.
*
* @param maxTimePerInvocationNanos the max time per invocation in nanoseconds
* @return the max time per invocation in nanoseconds
*/

public Builder maxTimePerInvocationNanos(long maxTimePerInvocationNanos) {
this.maxTimePerInvocationNanos = maxTimePerInvocationNanos;
return this;
}
/**
* Invocation times in nanoseconds.
*
* @param invocationTimesNanos the invocation times in nanoseconds
* @return the invocation times in nanoseconds
*/

public Builder invocationTimesNanos(List<Long> invocationTimesNanos) {
this.invocationTimesNanos = new ArrayList<>(invocationTimesNanos);
return this;
}
/** {@return the build} */

public BenchmarkResult build() {
return new BenchmarkResult(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
boolean isSameValue(Object v1, Object v2) {
if (v1 == null && v2 == null) return true;
if (v1 == null || v2 == null) return false;
return v1.equals(v2) || v1 == v2;

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Load Tests (JDK 21)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Gradle Examples Shard 1 (PR)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Gradle Examples Shard 0 (PR)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Gradle Examples Shard 2 (PR)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Gradle Examples Shard 3 (PR)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Consumer Fixture (Java 25)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Consumer Fixture (Java 21)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Examples Shard 1 (PR)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Examples Shard 3 (PR)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Examples Shard 2 (PR)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Examples Shard 0 (PR)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Test Suite (25, macos-latest)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Test Suite (21, macos-latest)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Test Suite (25, ubuntu-latest)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Gradle Test Suite (21)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Test Suite (21, ubuntu-latest)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Build Gradle Project (21)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Build Maven Project (25)

[ReferenceEquality] Comparison using reference equality instead of value equality

Check warning on line 58 in async-test-lib/src/main/java/se/deversity/asynctest/diagnostics/ABAProblemDetector.java

View workflow job for this annotation

GitHub Actions / Build Maven Project (21)

[ReferenceEquality] Comparison using reference equality instead of value equality
}
}

Expand Down Expand Up @@ -213,20 +213,30 @@
public ABAReport analyze() {
return analyzeABA();
}
/**
* Clears recorded the observation so this instance can be reused for the next run.
*/

public void reset() {
trackedVariables.clear();
}
/**
* Disable.
*/

public void disable() {
enabled = false;
}
/**
* Enable.
*/

public void enable() {
enabled = true;
}

public static class ABAReport {
/** The variables with cycles. */
public final Map<String, Integer> variablesWithCycles = new HashMap<>();
/** The successful ABA cases. */
public final Set<String> successfulABACases = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ private static class FieldAccessRecord {
*/
private final Queue<String> atomicityViolations = new ConcurrentLinkedQueue<>();
private volatile boolean enabled = true;
/**
* Records compound operation start so it can be analysed at the end of the run.
*
* @param operationName the operation name
*/

public void recordCompoundOperationStart(String operationName) {
if (!enabled || operationName == null || operationName.isBlank()) {
Expand All @@ -56,6 +61,11 @@ public void recordCompoundOperationStart(String operationName) {
activeOperations.put(operationKey(operationName),
new CompoundOperation(operationName, Thread.currentThread().threadId()));
}
/**
* Records compound operation end so it can be analysed at the end of the run.
*
* @param operationName the operation name
*/

public void recordCompoundOperationEnd(String operationName) {
if (!enabled || operationName == null || operationName.isBlank()) {
Expand All @@ -64,6 +74,13 @@ public void recordCompoundOperationEnd(String operationName) {

activeOperations.remove(operationKey(operationName));
}
/**
* Records field access so it can be analysed at the end of the run.
*
* @param fieldName the field name
* @param value the value
* @param isWrite the is write
*/

public void recordFieldAccess(String fieldName, @Nullable Object value, boolean isWrite) {
recordFieldAccess(fieldName, value, isWrite, Thread.currentThread().threadId());
Expand Down Expand Up @@ -122,6 +139,15 @@ public void recordFieldAccess(String fieldName, @Nullable Object value, boolean
}
}
}
/**
* Detect check then act violation.
*
* @param fieldName the field name
* @param checkValue the check value
* @param expectedValue the expected value
* @param wouldAct the would act
* @return the detect check then act violation
*/

public boolean detectCheckThenActViolation(String fieldName, Object checkValue,
Object expectedValue, boolean wouldAct) {
Expand All @@ -138,6 +164,11 @@ public boolean detectCheckThenActViolation(String fieldName, Object checkValue,
}
return violation;
}
/**
* Analyses what has been recorded about atomicity and builds the report for it.
*
* @return the analyze atomicity
*/

public AtomicityReport analyzeAtomicity() {
AtomicityReport report = new AtomicityReport();
Expand Down Expand Up @@ -185,16 +216,25 @@ public AtomicityReport analyze() {
private String operationKey(String operationName) {
return Thread.currentThread().threadId() + ":" + operationName;
}
/**
* Clears recorded the observation so this instance can be reused for the next run.
*/

public void reset() {
activeOperations.clear();
fieldHistory.clear();
atomicityViolations.clear();
}
/**
* Disable.
*/

public void disable() {
enabled = false;
}
/**
* Enable.
*/

public void enable() {
enabled = true;
Expand Down
Loading
Loading