mirror of
https://github.com/xerial/snappy-java.git
synced 2025-07-23 05:54:41 +02:00
Add test code to see the performance
This commit is contained in:
parent
f762770ef1
commit
5b5a3a379d
@ -47,11 +47,13 @@ pomExtra := {
|
|||||||
</scm>
|
</scm>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scalaVersion := "2.11.1"
|
||||||
|
|
||||||
javacOptions in (Compile, compile) ++= Seq("-encoding", "UTF-8", "-Xlint:unchecked", "-Xlint:deprecation", "-source", "1.6", "-target", "1.6")
|
javacOptions in (Compile, compile) ++= Seq("-encoding", "UTF-8", "-Xlint:unchecked", "-Xlint:deprecation", "-source", "1.6", "-target", "1.6")
|
||||||
|
|
||||||
testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v")
|
testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v")
|
||||||
|
|
||||||
//concurrentRestrictions in Global := Seq(Tags.limit(Tags.Test, 1))
|
concurrentRestrictions in Global := Seq(Tags.limit(Tags.Test, 1))
|
||||||
|
|
||||||
autoScalaLibrary := false
|
autoScalaLibrary := false
|
||||||
|
|
||||||
@ -64,7 +66,9 @@ incOptions := incOptions.value.withNameHashing(true)
|
|||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"junit" % "junit" % "4.8.2" % "test",
|
"junit" % "junit" % "4.8.2" % "test",
|
||||||
"org.codehaus.plexus" % "plexus-classworlds" % "2.4" % "test",
|
"org.codehaus.plexus" % "plexus-classworlds" % "2.4" % "test",
|
||||||
"org.xerial" % "xerial-core" % "1.0.21" % "test",
|
"org.xerial.java" % "xerial-core" % "2.1" % "test",
|
||||||
|
"org.xerial" % "xerial-core" % "3.2.3" % "test",
|
||||||
|
"org.scalatest" % "scalatest_2.11" % "2.2.0" % "test",
|
||||||
"org.osgi" % "org.osgi.core" % "4.3.0" % "provided",
|
"org.osgi" % "org.osgi.core" % "4.3.0" % "provided",
|
||||||
"com.novocode" % "junit-interface" % "0.10" % "test"
|
"com.novocode" % "junit-interface" % "0.10" % "test"
|
||||||
)
|
)
|
||||||
|
48
src/test/scala/org/xerial/snappy/SnappyPerformanceTest.scala
Normal file
48
src/test/scala/org/xerial/snappy/SnappyPerformanceTest.scala
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package org.xerial.snappy
|
||||||
|
|
||||||
|
import java.io.{ByteArrayOutputStream, ByteArrayInputStream}
|
||||||
|
|
||||||
|
import xerial.core.log.LogLevel
|
||||||
|
|
||||||
|
import scala.util.Random
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class SnappyPerformanceTest extends SnappySpec {
|
||||||
|
|
||||||
|
lazy val data = {
|
||||||
|
val a = new Array[Byte](32 * 1024 * 1024)
|
||||||
|
|
||||||
|
for (i <- (0 until a.length).par) {
|
||||||
|
a(i) = Math.sin(i * 0.01).toByte
|
||||||
|
}
|
||||||
|
a
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
"SnappyOutputStream" should {
|
||||||
|
|
||||||
|
"improve output performance" taggedAs("out") in {
|
||||||
|
|
||||||
|
val input = data
|
||||||
|
|
||||||
|
time("compression", repeat=100, logLevel = LogLevel.INFO) {
|
||||||
|
block("default") {
|
||||||
|
val out = new ByteArrayOutputStream()
|
||||||
|
val sout = new SnappyOutputStream(out)
|
||||||
|
sout.write(input)
|
||||||
|
out.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//info(f"compressed size: ${compressed.length}%,d, input: ${data.length}%,d")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
22
src/test/scala/org/xerial/snappy/SnappySpec.scala
Normal file
22
src/test/scala/org/xerial/snappy/SnappySpec.scala
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package org.xerial.snappy
|
||||||
|
|
||||||
|
import org.scalatest._
|
||||||
|
import xerial.core.log.Logger
|
||||||
|
import xerial.core.util.Timer
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
trait SnappySpec
|
||||||
|
extends WordSpec
|
||||||
|
with Matchers
|
||||||
|
with GivenWhenThen
|
||||||
|
with OptionValues
|
||||||
|
with BeforeAndAfter
|
||||||
|
with Timer
|
||||||
|
with Logger
|
||||||
|
{
|
||||||
|
|
||||||
|
implicit def toTag(s:String) : Tag = Tag(s)
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user