-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move JLBH classes from core package, closes #8
- Loading branch information
Showing
32 changed files
with
1,336 additions
and
11 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
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
1 change: 1 addition & 0 deletions
1
src/main/java/net/openhft/chronicle/core/jlbh/LatencyDistributor.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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package net.openhft.chronicle.core.jlbh; | ||
|
||
@FunctionalInterface | ||
@Deprecated(/* moved from net.openhft.chronicle.core.jlbh to net.openhft.chronicle.jlbh */) | ||
public interface LatencyDistributor { | ||
long apply(long averageLatencyNS); | ||
} |
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
51 changes: 51 additions & 0 deletions
51
src/main/java/net/openhft/chronicle/jlbh/ImmutableJLBHResult.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,51 @@ | ||
/* | ||
* Copyright 2016-2020 chronicle.software | ||
* | ||
* https://chronicle.software | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package net.openhft.chronicle.jlbh; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import static java.util.Collections.unmodifiableMap; | ||
|
||
class ImmutableJLBHResult implements JLBHResult { | ||
|
||
@NotNull | ||
private final ProbeResult endToEndProbeResult; | ||
@NotNull | ||
private final Map<String, ProbeResult> additionalProbeResults; | ||
|
||
ImmutableJLBHResult(@NotNull ProbeResult endToEndProbeResult, @NotNull Map<String, ? extends ProbeResult> additionalProbeResults) { | ||
this.endToEndProbeResult = endToEndProbeResult; | ||
this.additionalProbeResults = unmodifiableMap(additionalProbeResults); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public ProbeResult endToEnd() { | ||
return endToEndProbeResult; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public Optional<ProbeResult> probe(String probeName) { | ||
return Optional.ofNullable(additionalProbeResults.get(probeName)); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/net/openhft/chronicle/jlbh/ImmutableProbeResult.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,48 @@ | ||
/* | ||
* Copyright 2016-2020 chronicle.software | ||
* | ||
* https://chronicle.software | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package net.openhft.chronicle.jlbh; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
import static java.util.Collections.unmodifiableList; | ||
import static java.util.stream.Collectors.toList; | ||
|
||
class ImmutableProbeResult implements JLBHResult.ProbeResult { | ||
|
||
@NotNull | ||
private final List<JLBHResult.RunResult> runsSummary; | ||
|
||
public ImmutableProbeResult(List<double[]> percentileRuns) { | ||
runsSummary = unmodifiableList(percentileRuns.stream().map(ImmutableRunResult::new).collect(toList())); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public JLBHResult.RunResult summaryOfLastRun() { | ||
return runsSummary.get(runsSummary.size() - 1); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public List<JLBHResult.RunResult> eachRunSummary() { | ||
return runsSummary; | ||
} | ||
} |
130 changes: 130 additions & 0 deletions
130
src/main/java/net/openhft/chronicle/jlbh/ImmutableRunResult.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,130 @@ | ||
/* | ||
* Copyright 2016-2020 chronicle.software | ||
* | ||
* https://chronicle.software | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package net.openhft.chronicle.jlbh; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.time.Duration; | ||
import java.util.EnumMap; | ||
import java.util.Map; | ||
|
||
import static java.time.temporal.ChronoUnit.NANOS; | ||
import static java.util.Collections.unmodifiableMap; | ||
import static net.openhft.chronicle.jlbh.JLBHResult.RunResult.Percentile.*; | ||
|
||
class ImmutableRunResult implements JLBHResult.RunResult { | ||
|
||
private final Map<Percentile, Duration> percentiles; | ||
|
||
public ImmutableRunResult(double[] percentiles) { | ||
this.percentiles = asMap(percentiles); | ||
} | ||
|
||
private static Map<Percentile, Duration> asMap(double[] percentiles) { | ||
final Map<Percentile, Duration> data = new EnumMap<>(Percentile.class); | ||
// TODO: duplicate of knowledge with Histogram.percentilesFor() | ||
data.put(PERCENTILE_50TH, durationOf(percentiles[0])); | ||
data.put(PERCENTILE_90TH, durationOf(percentiles[1])); | ||
data.put(PERCENTILE_99TH, durationOf(percentiles[2])); | ||
if (percentiles.length > 4) { | ||
data.put(PERCENTILE_99_7TH, durationOf(percentiles[3])); | ||
} | ||
if (percentiles.length > 5) { | ||
data.put(PERCENTILE_99_9TH, durationOf(percentiles[4])); | ||
} | ||
if (percentiles.length > 6) { | ||
data.put(PERCENTILE_99_97TH, durationOf(percentiles[5])); | ||
} | ||
if (percentiles.length > 7) { | ||
data.put(PERCENTILE_99_99TH, durationOf(percentiles[6])); | ||
} | ||
data.put(WORST, durationOf(percentiles[percentiles.length - 1])); | ||
return unmodifiableMap(data); | ||
} | ||
|
||
private static Duration durationOf(double percentile) { | ||
return Duration.of((long) percentile, NANOS); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public Map<Percentile, Duration> percentiles() { | ||
return percentiles; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public Duration get50thPercentile() { | ||
return percentiles.get(PERCENTILE_50TH); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public Duration get90thPercentile() { | ||
return percentiles.get(PERCENTILE_90TH); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public Duration get99thPercentile() { | ||
return percentiles.get(PERCENTILE_99TH); | ||
} | ||
|
||
@Override | ||
@Nullable | ||
public Duration get999thPercentile() { | ||
return percentiles.get(PERCENTILE_99_9TH); | ||
} | ||
|
||
@Override | ||
@Nullable | ||
public Duration get9999thPercentile() { | ||
return percentiles.get(PERCENTILE_99_99TH); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public Duration getWorst() { | ||
return percentiles.get(WORST); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ImmutableRunResult{" + | ||
"percentiles=" + percentiles + | ||
'}'; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
ImmutableRunResult summary = (ImmutableRunResult) o; | ||
|
||
return percentiles.equals(summary.percentiles); | ||
|
||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return percentiles.hashCode(); | ||
} | ||
} |
Oops, something went wrong.