Class CipherBenchmark

java.lang.Object
moe.kyokobot.koe.experimental.crypto.CipherBenchmark

public final class CipherBenchmark extends Object
A rough benchmark of the encryption modes on the current JVM, good enough to tell which ones are fast here.
  • Field Details

    • DEFAULT_WARMUP

      public static final Duration DEFAULT_WARMUP
    • DEFAULT_ROUND

      public static final Duration DEFAULT_ROUND
    • DEFAULT_ROUNDS

      public static final int DEFAULT_ROUNDS
      See Also:
  • Method Details

    • run

      @NotNull public static @NotNull CipherBenchmark.Report 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 for warmup + round * rounds per 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 it
      round - how long to measure every mode in a round, modes take turns between rounds
      rounds - 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, see run(Duration, Duration, int).
      Parameters:
      modes - names of the encryption modes to measure
      Returns:
      the results
      Throws:
      IllegalArgumentException - if a mode isn't supported
    • currentEnvironment

      @NotNull public static @NotNull Map<String,String> currentEnvironment()
      Returns:
      what the results depend on besides Koe itself: the JVM, the OS, the CPU and whether HotSpot uses AES instructions