-
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.
Prepared for include into zip implementation
- Loading branch information
1 parent
c026120
commit 18367b8
Showing
13 changed files
with
115 additions
and
17 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
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
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
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
51 changes: 51 additions & 0 deletions
51
src/main/scala/org/virtuslab/zipops/bench/IncludeFilesBenchmark.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,51 @@ | ||
package org.virtuslab.zipops.bench | ||
|
||
import org.virtuslab.zipops.ZipOps | ||
import java.io.File | ||
|
||
import ZipOpsBench._ | ||
|
||
import org.openjdk.jmh.annotations._ | ||
import sbt.io.{ IO, DirectoryFilter } | ||
|
||
class IncludeSomeFilesBench extends IncludeFilesBenchmark(zip = BigJar, zipToExtractAndInclude = SmallJar) | ||
|
||
@State(Scope.Thread) | ||
abstract class IncludeFilesBenchmark( | ||
zip: String, | ||
zipToExtractAndInclude: String | ||
) extends ZipOpsBench with BenchUtil { | ||
|
||
var zipFile: File = _ | ||
var extractDir: File = _ | ||
var extractedFiles: Seq[(File, String)] = _ | ||
|
||
@Setup(Level.Invocation) | ||
def setup(): Unit = { | ||
zipFile = copyResource(zip) | ||
|
||
val zipToExtract = copyResource(zipToExtractAndInclude) | ||
extractDir = extractSomewhere(zipToExtract).toFile | ||
extractedFiles = dirContent(extractDir) | ||
} | ||
|
||
private def dirContent(dir: File): Seq[(File, String)] = { | ||
import sbt.io.syntax._ | ||
(dir ** -DirectoryFilter).get.flatMap { extractedFile => | ||
IO.relativize(dir, extractedFile) match { | ||
case Some(relPath) => | ||
List((extractedFile, relPath)) | ||
case _ => Nil | ||
} | ||
} | ||
} | ||
|
||
@TearDown(Level.Invocation) | ||
def teardown(): Unit = { | ||
zipFile.delete() | ||
IO.delete(extractDir) | ||
} | ||
|
||
override def run(ops: ZipOps): Unit = ops.includeFiles(zipFile, extractedFiles) | ||
|
||
} |
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
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
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