Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backport of performance test support from master
- Loading branch information
Showing
14 changed files
with
769 additions
and
5 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
57 changes: 57 additions & 0 deletions
57
infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestReportUtil.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,57 @@ | ||
/* | ||
* Copyright (C) 2010-2020 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.test.util; | ||
|
||
import java.util.Comparator; | ||
|
||
import com.evolveum.midpoint.schema.statistics.OperationsPerformanceInformationUtil; | ||
import com.evolveum.midpoint.tools.testng.TestMonitor; | ||
import com.evolveum.midpoint.tools.testng.TestReportSection; | ||
import com.evolveum.midpoint.util.statistics.OperationsPerformanceMonitor; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationsPerformanceInformationType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.SingleOperationPerformanceInformationType; | ||
|
||
public class TestReportUtil { | ||
|
||
public static void reportPerfData(TestMonitor testMonitor) { | ||
OperationsPerformanceInformationType performanceInformation = | ||
OperationsPerformanceInformationUtil.toOperationsPerformanceInformationType( | ||
OperationsPerformanceMonitor.INSTANCE.getGlobalPerformanceInformation()); | ||
TestReportSection section = testMonitor.addReportSection("globalPerformanceInformation") | ||
.withColumns("Operation", "Count", "Total time (ms)", "Min", "Max", "Avg"); | ||
|
||
performanceInformation.getOperation().stream() | ||
.sorted(Comparator.comparing(SingleOperationPerformanceInformationType::getTotalTime).reversed()) | ||
.forEach(op -> { | ||
int count = zeroIfNull(op.getInvocationCount()); | ||
float totalTime = zeroIfNull(op.getTotalTime()) / 1000.0f; | ||
section.addRow( | ||
op.getName(), | ||
count, | ||
totalTime, | ||
zeroIfNull(op.getMinTime()) / 1000.0f, | ||
zeroIfNull(op.getMaxTime()) / 1000.0f, | ||
avg(totalTime, count)); | ||
}); | ||
// TODO: How to adapt this to the code above? See OperationsPerformanceInformationPrinter for the details. | ||
// OperationsPerformanceInformationUtil.format(performanceInformation, | ||
// new AbstractStatisticsPrinter.Options(CSV, TIME), null, null)); | ||
} | ||
|
||
// TODO: cleanup! taken from AbstractStatisticsPrinter | ||
private static int zeroIfNull(Integer n) { | ||
return n != null ? n : 0; | ||
} | ||
|
||
private static long zeroIfNull(Long n) { | ||
return n != null ? n : 0; | ||
} | ||
|
||
private static Number avg(Number total, int count) { | ||
return total != null && count > 0 ? total.floatValue() / count : null; | ||
} | ||
} |
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.