-
-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Benchmark cap CPU profile to 100%
- Loading branch information
1 parent
39e4d19
commit 2ddb4df
Showing
4 changed files
with
70 additions
and
41 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
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
55 changes: 55 additions & 0 deletions
55
perf/BenchmarkApp/PerformanceTest.Shared/Reporting/OutlinerHelper.cs
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,55 @@ | ||
namespace PerformanceTest.Shared.Reporting; | ||
|
||
public static partial class OutlinerHelper | ||
{ | ||
public static IReadOnlyList<double> RemoveOutlinerByIQR(IReadOnlyList<double> data, double upperLimit) | ||
{ | ||
if (data.Count == 0) | ||
return data; | ||
|
||
// sort rps, latency.mean | ||
var sirted = data.OrderBy(x => x).ToArray(); | ||
|
||
// get outliner for rps | ||
var lowerBound = GetLowerBound(sirted); | ||
var upperBound = GetUpperBound(sirted); | ||
|
||
// compute tuple in range | ||
var filteredData = data | ||
.Where(x => x >= lowerBound && x <= upperBound) | ||
.Where(x => x <= upperLimit) | ||
.ToArray(); | ||
|
||
return filteredData; | ||
} | ||
|
||
internal static double GetLowerBound(IReadOnlyList<double> sortedData) | ||
{ | ||
var Q1 = GetPercentile(sortedData, 25); | ||
var Q3 = GetPercentile(sortedData, 75); | ||
var IQR = Q3 - Q1; | ||
return Q1 - 1.5 * IQR; | ||
} | ||
|
||
internal static double GetUpperBound(IReadOnlyList<double> sortedData) | ||
{ | ||
if (sortedData.Count == 0) | ||
return sortedData[0]; | ||
|
||
var Q1 = GetPercentile(sortedData, 25); | ||
var Q3 = GetPercentile(sortedData, 75); | ||
var IQR = Q3 - Q1; | ||
return Q3 + 1.5 * IQR; | ||
} | ||
|
||
private static double GetPercentile(IReadOnlyList<double> sortedData, double percentile) | ||
{ | ||
var N = sortedData.Count; | ||
var n = (N - 1) * percentile / 100.0 + 1; | ||
if (n == 1) return sortedData[0]; | ||
if (n == N) return sortedData[N - 1]; | ||
var k = (int)Math.Floor(n) - 1; | ||
var d = n - Math.Floor(n); | ||
return sortedData[k] + d * (sortedData[k + 1] - sortedData[k]); | ||
} | ||
} |