From 5b5a3a379db72143fbcf6a4c90cba27258e611b5 Mon Sep 17 00:00:00 2001 From: "Taro L. Saito" Date: Fri, 18 Jul 2014 16:22:59 +0900 Subject: [PATCH] Add test code to see the performance --- build.sbt | 8 +++- .../xerial/snappy/SnappyPerformanceTest.scala | 48 +++++++++++++++++++ .../scala/org/xerial/snappy/SnappySpec.scala | 22 +++++++++ 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 src/test/scala/org/xerial/snappy/SnappyPerformanceTest.scala create mode 100644 src/test/scala/org/xerial/snappy/SnappySpec.scala diff --git a/build.sbt b/build.sbt index 58c57de..dab77b0 100644 --- a/build.sbt +++ b/build.sbt @@ -47,11 +47,13 @@ pomExtra := { } +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" ) diff --git a/src/test/scala/org/xerial/snappy/SnappyPerformanceTest.scala b/src/test/scala/org/xerial/snappy/SnappyPerformanceTest.scala new file mode 100644 index 0000000..d60c164 --- /dev/null +++ b/src/test/scala/org/xerial/snappy/SnappyPerformanceTest.scala @@ -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") + } + + + + } + +} diff --git a/src/test/scala/org/xerial/snappy/SnappySpec.scala b/src/test/scala/org/xerial/snappy/SnappySpec.scala new file mode 100644 index 0000000..1b66135 --- /dev/null +++ b/src/test/scala/org/xerial/snappy/SnappySpec.scala @@ -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) + +}