Class CipherBenchmark
java.lang.Object
moe.kyokobot.koe.experimental.crypto.CipherBenchmark
A rough benchmark of the encryption modes on the current JVM, good enough to tell which ones are fast here.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final classResults of a benchmark run, which can be stored as JSON to avoid running it on every start. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull CipherBenchmark.Reportrun()Measures every supported encryption mode with the default durations, about 100ms per mode.static @NotNull CipherBenchmark.ReportMeasures every supported encryption mode.static @NotNull CipherBenchmark.Reportrun(@NotNull Duration warmup, @NotNull Duration round, int rounds, @NotNull Collection<String> modes) Measures the given encryption modes, seerun(Duration, Duration, int).
-
Field Details
-
DEFAULT_WARMUP
-
DEFAULT_ROUND
-
DEFAULT_ROUNDS
public static final int DEFAULT_ROUNDS- See Also:
-
-
Method Details
-
run
Measures every supported encryption mode with the default durations, about 100ms per mode.- Returns:
- the results
- See Also:
-
run
@NotNull public static @NotNull CipherBenchmark.Report run(@NotNull @NotNull Duration warmup, @NotNull @NotNull Duration round, int rounds) Measures every supported encryption mode. Blocks the calling thread forwarmup + round * roundsper mode, so call it once at startup, never on an event loop thread. Longer rounds give more stable results.- Parameters:
warmup- how long to run every mode before measuring, so the JIT compiler has optimized itround- how long to measure every mode in a round, modes take turns between roundsrounds- number of rounds, the median of them is the result- Returns:
- the results
-
run
@NotNull public static @NotNull CipherBenchmark.Report run(@NotNull @NotNull Duration warmup, @NotNull @NotNull Duration round, int rounds, @NotNull @NotNull Collection<String> modes) Measures the given encryption modes, seerun(Duration, Duration, int).- Parameters:
modes- names of the encryption modes to measure- Returns:
- the results
- Throws:
IllegalArgumentException- if a mode isn't supported
-
currentEnvironment
- Returns:
- what the results depend on besides Koe itself: the JVM, the OS, the CPU and whether HotSpot uses AES instructions
-