Class CipherBenchmark.Report

java.lang.Object
moe.kyokobot.koe.experimental.crypto.CipherBenchmark.Report
Enclosing class:
CipherBenchmark

public static final class CipherBenchmark.Report extends Object
Results of a benchmark run, which can be stored as JSON to avoid running it on every start.
  • Field Details

    • VERSION

      public static final int VERSION
      Bumped on significant changes to the encryption modes, which make older results misleading, and on incompatible changes to the JSON format. fromJson(String) rejects reports with another version.
      See Also:
  • Method Details

    • getCreatedAt

      @NotNull public @NotNull Instant getCreatedAt()
    • getEnvironment

      @NotNull public @NotNull Map<String,String> getEnvironment()
      See Also:
    • getPayloadSize

      public int getPayloadSize()
      Returns:
      the size of the payload encrypted in every packet, in bytes
    • getMeasurements

      @NotNull public @NotNull List<CipherBenchmark.Measurement> getMeasurements()
      Returns:
      measurements from the fastest to the slowest mode
    • isFromCurrentEnvironment

      public boolean isFromCurrentEnvironment()
      Returns:
      whether the results were measured on the same JVM, OS and CPU, otherwise they may not apply anymore and the benchmark should run again
    • toPolicy

      @NotNull public @NotNull CipherPreferencePolicy toPolicy()
      Returns:
      a policy preferring modes from the fastest to the slowest
    • toJson

      @NotNull public @NotNull String toJson()
    • fromJson

      @NotNull public static @NotNull CipherBenchmark.Report fromJson(@NotNull @NotNull String json)
      Parameters:
      json - a report from toJson()
      Returns:
      the parsed report
      Throws:
      IllegalArgumentException - if the JSON is malformed or the report has another VERSION
    • toString

      public String toString()
      Overrides:
      toString in class Object