Coverage Summary for Class: CompressionBenchmarks (lzwpack.bench)

Class Class, % Method, % Line, %
CompressionBenchmarks 0% (0/ 1) 0% (0/ 9) 0% (0/ 14)


1 package lzwpack.bench 2  3 import java.nio.file.{Path, Paths} 4 import java.util.concurrent.TimeUnit 5  6 import cats.effect.IO 7 import fs2.Sink 8 import lzwpack._ 9 import org.openjdk.jmh.annotations._ 10  11 // jmh:run -i 10 -wi 10 -f1 -t1 lzwpack.bench.* 12 @BenchmarkMode(Array(Mode.AverageTime)) 13 @OutputTimeUnit(TimeUnit.SECONDS) 14 @State(Scope.Thread) 15 class CompressionBenchmarks { 16  val sink: Sink[IO, Byte] = fs2.io.file.writeAll(Paths.get("/dev/null")) 17  18  import Alphabet.Compress 19  20  def benchmarkCompress(fixture: Path): IO[Unit] = { 21  Application.runCompress(fixture, 16, sink) 22  } 23  24  def benchmarkDecompress(fixture: Path): IO[Unit] = { 25  Application.runCompress(fixture, 16, sink) 26  } 27  28  // Alice29 = 149KB 29  @Benchmark def compressAlice29(): Unit = { 30  benchmarkCompress(Paths.get("fixtures/alice29.txt")).unsafeRunSync() 31  } 32  33  @Benchmark def compressAlice29WithoutPack(): Unit = { 34  fs2.io.file.readAll[IO](Paths.get("fixtures/alice29.txt"), 4028) 35  .through(LZW.compress) 36  .compile.drain.unsafeRunSync() 37  } 38  39  @Benchmark def decompressAlice29(): Unit = { 40  benchmarkDecompress(Paths.get("fixtures/compress/alice29.txt.Z")).unsafeRunSync() 41  } 42  43  @Benchmark def unpackAlice29(): Unit = { 44  fs2.io.file.readAll[IO](Paths.get("fixtures/alice29.noheader.txt.Z"), 4028) 45  .through(Format.unpack) 46  .compile.drain.unsafeRunSync() 47  } 48  49  // Ptt5 = 501K 50  @Benchmark def compressPtt5(): Unit = { 51  benchmarkCompress(Paths.get("fixtures/ptt5")).unsafeRunSync() 52  } 53  54  55  @Benchmark def decompressPtt5(): Unit = { 56  benchmarkCompress(Paths.get("fixtures/compress/ptt5.Z")).unsafeRunSync() 57  } 58 }