Skip to content

Commit 5b5a3a3

Browse files
committed
Add test code to see the performance
1 parent f762770 commit 5b5a3a3

File tree

3 files changed

+76
-2
lines changed

3 files changed

+76
-2
lines changed

build.sbt

+6-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ pomExtra := {
4747
</scm>
4848
}
4949

50+
scalaVersion := "2.11.1"
51+
5052
javacOptions in (Compile, compile) ++= Seq("-encoding", "UTF-8", "-Xlint:unchecked", "-Xlint:deprecation", "-source", "1.6", "-target", "1.6")
5153

5254
testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v")
5355

54-
//concurrentRestrictions in Global := Seq(Tags.limit(Tags.Test, 1))
56+
concurrentRestrictions in Global := Seq(Tags.limit(Tags.Test, 1))
5557

5658
autoScalaLibrary := false
5759

@@ -64,7 +66,9 @@ incOptions := incOptions.value.withNameHashing(true)
6466
libraryDependencies ++= Seq(
6567
"junit" % "junit" % "4.8.2" % "test",
6668
"org.codehaus.plexus" % "plexus-classworlds" % "2.4" % "test",
67-
"org.xerial" % "xerial-core" % "1.0.21" % "test",
69+
"org.xerial.java" % "xerial-core" % "2.1" % "test",
70+
"org.xerial" % "xerial-core" % "3.2.3" % "test",
71+
"org.scalatest" % "scalatest_2.11" % "2.2.0" % "test",
6872
"org.osgi" % "org.osgi.core" % "4.3.0" % "provided",
6973
"com.novocode" % "junit-interface" % "0.10" % "test"
7074
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.xerial.snappy
2+
3+
import java.io.{ByteArrayOutputStream, ByteArrayInputStream}
4+
5+
import xerial.core.log.LogLevel
6+
7+
import scala.util.Random
8+
9+
10+
/**
11+
*
12+
*/
13+
class SnappyPerformanceTest extends SnappySpec {
14+
15+
lazy val data = {
16+
val a = new Array[Byte](32 * 1024 * 1024)
17+
18+
for (i <- (0 until a.length).par) {
19+
a(i) = Math.sin(i * 0.01).toByte
20+
}
21+
a
22+
}
23+
24+
25+
"SnappyOutputStream" should {
26+
27+
"improve output performance" taggedAs("out") in {
28+
29+
val input = data
30+
31+
time("compression", repeat=100, logLevel = LogLevel.INFO) {
32+
block("default") {
33+
val out = new ByteArrayOutputStream()
34+
val sout = new SnappyOutputStream(out)
35+
sout.write(input)
36+
out.close()
37+
}
38+
39+
}
40+
41+
//info(f"compressed size: ${compressed.length}%,d, input: ${data.length}%,d")
42+
}
43+
44+
45+
46+
}
47+
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.xerial.snappy
2+
3+
import org.scalatest._
4+
import xerial.core.log.Logger
5+
import xerial.core.util.Timer
6+
7+
/**
8+
*
9+
*/
10+
trait SnappySpec
11+
extends WordSpec
12+
with Matchers
13+
with GivenWhenThen
14+
with OptionValues
15+
with BeforeAndAfter
16+
with Timer
17+
with Logger
18+
{
19+
20+
implicit def toTag(s:String) : Tag = Tag(s)
21+
22+
}

0 commit comments

Comments
 (0)