Add test code to see the performance
This commit is contained in:
parent
f762770ef1
commit
5b5a3a379d
|
@ -47,11 +47,13 @@ pomExtra := {
|
|||
</scm>
|
||||
}
|
||||
|
||||
scalaVersion := "2.11.1"
|
||||
|
||||
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")
|
||||
|
||||
//concurrentRestrictions in Global := Seq(Tags.limit(Tags.Test, 1))
|
||||
concurrentRestrictions in Global := Seq(Tags.limit(Tags.Test, 1))
|
||||
|
||||
autoScalaLibrary := false
|
||||
|
||||
|
@ -64,7 +66,9 @@ incOptions := incOptions.value.withNameHashing(true)
|
|||
libraryDependencies ++= Seq(
|
||||
"junit" % "junit" % "4.8.2" % "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",
|
||||
"com.novocode" % "junit-interface" % "0.10" % "test"
|
||||
)
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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…
Reference in New Issue