-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f44a699
commit a85248e
Showing
4 changed files
with
73 additions
and
20 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
53 changes: 53 additions & 0 deletions
53
src/main/scala/org/virtuslab/zipops/bench/ExistenceCheckBenchmark.scala
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,53 @@ | ||
package org.virtuslab.zipops.bench | ||
|
||
import org.virtuslab.zipops.ZipOps | ||
import java.io.File | ||
import java.util.concurrent.TimeUnit.{ SECONDS, MILLISECONDS } | ||
|
||
import org.openjdk.jmh.annotations._ | ||
import org.openjdk.jmh.infra.Blackhole | ||
import org.virtuslab.zipops.ZipOps.InZipPath | ||
import org.virtuslab.zipops.bench.ZipOpsBench._ | ||
import org.virtuslab.zipops.impl.MyZipFsOps | ||
|
||
class BigJarExistenceTestBench extends ExistenceCheckBenchmark(BigJar) | ||
class SmallJarExistenceTestBench extends ExistenceCheckBenchmark(SmallJar) | ||
|
||
@State(Scope.Thread) | ||
abstract class ExistenceCheckBenchmark(jar: String) extends ZipOpsBench with BenchUtil { | ||
|
||
var jarFile: File = _ | ||
var extractDir: File = _ | ||
var paths: Seq[InZipPath] = _ | ||
var extractedFiles: Seq[File] = _ | ||
|
||
@Setup(Level.Trial) | ||
def setup(): Unit = { | ||
jarFile = copyResource(jar) | ||
paths = MyZipFsOps.readPaths(jarFile) | ||
|
||
extractDir = extractSomewhere(jarFile).toFile | ||
extractedFiles = dirContent(extractDir).map(_._1) | ||
} | ||
|
||
@TearDown(Level.Trial) | ||
def teardown(): Unit = { | ||
jarFile.delete() | ||
} | ||
|
||
override def run(ops: ZipOps): Unit = { | ||
val allPaths =ops.readPaths(jarFile) | ||
paths.foreach(allPaths.contains) | ||
} | ||
|
||
@Benchmark | ||
@Fork(value = 1) | ||
@Warmup(iterations = WarmupIterations, time = WarmupIterationTime, timeUnit = SECONDS) | ||
@Measurement(iterations = Iterations, time = IterationTime, timeUnit = SECONDS) | ||
@BenchmarkMode(Array(Mode.AverageTime)) | ||
@OutputTimeUnit(MILLISECONDS) | ||
def files(hole: Blackhole): Unit = { | ||
extractedFiles.foreach(_.exists()) | ||
} | ||
|
||
} |
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