Skip to content

Commit

Permalink
Refactor and adjust config
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszwawrzyk committed Aug 2, 2018
1 parent 433f475 commit 41f3a33
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 45 deletions.
31 changes: 31 additions & 0 deletions src/main/scala/org/virtuslab/zipops/bench/BenchUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,37 @@ package org.virtuslab.zipops.bench

import java.io.File
import java.nio.file.{ Files, StandardCopyOption }
import java.util.concurrent.TimeUnit.SECONDS

import org.openjdk.jmh.annotations._
import org.virtuslab.zipops.{ Zip4jZipOps, ZipFsZipOps, ZipOps }

trait ZipOpsBench {

def run(ops: ZipOps): Unit

@Benchmark
@Fork(value = 1)
@Warmup(iterations = 10, time = 10, timeUnit = SECONDS)
@Measurement(iterations = 15, time = 15, timeUnit = SECONDS)
@BenchmarkMode(Array(Mode.Throughput))
@OutputTimeUnit(SECONDS)
def zip4j(): Unit = {
run(Zip4jZipOps)
}

@Benchmark
@Fork(value = 1)
@Warmup(iterations = 10, time = 10, timeUnit = SECONDS)
@Measurement(iterations = 15, time = 15, timeUnit = SECONDS)
@BenchmarkMode(Array(Mode.Throughput))
@OutputTimeUnit(SECONDS)
def zipfs(): Unit = {
run(ZipFsZipOps)
}


}

trait BenchUtil {

Expand Down
25 changes: 3 additions & 22 deletions src/main/scala/org/virtuslab/zipops/bench/DeleteBenchmarks.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package org.virtuslab.zipops.bench

import java.io.File
import java.util.concurrent.TimeUnit.SECONDS

import org.openjdk.jmh.annotations._
import org.virtuslab.zipops.{ Zip4jZipOps, ZipFsZipOps }
import org.virtuslab.zipops.ZipOps

class BigJarDeleteBench extends DeleteBenchmark("scala-library-2.12.6.jar") {

Expand Down Expand Up @@ -45,7 +44,7 @@ class SmallJarDeleteBench extends DeleteBenchmark("scala-xml_2.12-1.0.6.jar") {
}

@State(Scope.Thread)
abstract class DeleteBenchmark(jar: String) extends BenchUtil {
abstract class DeleteBenchmark(jar: String) extends ZipOpsBench with BenchUtil {

var jarFile: File = _

Expand All @@ -61,23 +60,5 @@ abstract class DeleteBenchmark(jar: String) extends BenchUtil {
jarFile.delete()
}

@Benchmark
@Fork(value = 1)
@Warmup(iterations = 3, time = 10, timeUnit = SECONDS)
@Measurement(iterations = 5, time = 10, timeUnit = SECONDS)
@BenchmarkMode(Array(Mode.Throughput))
@OutputTimeUnit(SECONDS)
def zip4jRemove(): Unit = {
Zip4jZipOps.removeEntries(jarFile, toDelete)
}

@Benchmark
@Fork(value = 1)
@Warmup(iterations = 3, time = 10, timeUnit = SECONDS)
@Measurement(iterations = 5, time = 10, timeUnit = SECONDS)
@BenchmarkMode(Array(Mode.Throughput))
@OutputTimeUnit(SECONDS)
def zipfsRemove(): Unit = {
ZipFsZipOps.removeEntries(jarFile, toDelete)
}
override def run(ops: ZipOps): Unit = ops.removeEntries(jarFile, toDelete)
}
26 changes: 3 additions & 23 deletions src/main/scala/org/virtuslab/zipops/bench/MergeBenchmarks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ package org.virtuslab.zipops.bench

import java.io.File

import org.virtuslab.zipops.{ Zip4jZipOps, ZipFsZipOps }
import java.util.concurrent.TimeUnit.SECONDS

import org.virtuslab.zipops.ZipOps
import org.openjdk.jmh.annotations._

class MergeBenchSmall extends MergeBench("scala-xml_2.12-1.0.6.jar", "zip-ops_2.12-0.1.jar")

class MergeBenchBig extends MergeBench("scala-library-2.12.6.jar", "scala-xml_2.12-1.0.6.jar")

@State(Scope.Thread)
abstract class MergeBench(target: String, source: String) extends BenchUtil {
abstract class MergeBench(target: String, source: String) extends ZipOpsBench with BenchUtil {

var targetFile: File = _
var sourceFile: File = _
Expand All @@ -28,23 +26,5 @@ abstract class MergeBench(target: String, source: String) extends BenchUtil {
targetFile.delete()
}

@Benchmark
@Fork(value = 1)
@Warmup(iterations = 3, time = 10, timeUnit = SECONDS)
@Measurement(iterations = 5, time = 10, timeUnit = SECONDS)
@BenchmarkMode(Array(Mode.Throughput))
@OutputTimeUnit(SECONDS)
def zip4jMerge(): Unit = {
Zip4jZipOps.mergeArchives(targetFile, sourceFile)
}

@Benchmark
@Fork(value = 1)
@Warmup(iterations = 3, time = 10, timeUnit = SECONDS)
@Measurement(iterations = 5, time = 10, timeUnit = SECONDS)
@BenchmarkMode(Array(Mode.Throughput))
@OutputTimeUnit(SECONDS)
def zipfsMerge(): Unit = {
ZipFsZipOps.mergeArchives(targetFile, sourceFile)
}
override def run(ops: ZipOps): Unit = ops.mergeArchives(targetFile, sourceFile)
}

0 comments on commit 41f3a33

Please sign in to comment.