Created
April 9, 2015 02:10
-
-
Save JoshRosen/f2b568662c3c6011df08 to your computer and use it in GitHub Desktop.
Exploring whether changes to snappy-java have resulted in worse compression in newer versions
This file contains hidden or 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
name := "Snappy Benchmark" | |
version := "1.0" | |
scalaVersion := "2.10.4" | |
libraryDependencies += "org.xerial.snappy" % "snappy-java" % sys.env.getOrElse("SNAPPY_VERSION", "1.1.1.6") |
This file contains hidden or 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
import java.io._ | |
import org.xerial.snappy.SnappyOutputStream | |
object Main { | |
def main(args: Array[String]) { | |
val blockSize = sys.env.getOrElse("BLOCK_SIZE", "32768").toInt | |
val resetFrequency = sys.env.getOrElse("RESET_FREQUENCY", "100").toInt | |
val byteArrayOutputstream = new ByteArrayOutputStream() | |
val snappyOutputStream = new SnappyOutputStream(byteArrayOutputstream, blockSize) | |
val objectOutputStream = new ObjectOutputStream(snappyOutputStream) | |
val objects = 1 to 1000 | |
var counter = 0 | |
objects.foreach { obj => | |
objectOutputStream.write(obj) | |
counter += 1 | |
if (counter >= resetFrequency) { | |
objectOutputStream.reset() | |
counter = 0 | |
} | |
} | |
objectOutputStream.close() | |
println("SIZE=" + byteArrayOutputstream.toByteArray.size) | |
} | |
} |
This file contains hidden or 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
#!/usr/bin/env bash | |
SNAPPY_VERSIONS=( | |
1.1.1.6 | |
1.1.1.5 | |
1.1.1.4 | |
1.1.1.3 | |
1.1.1.2 | |
1.1.1.1 | |
1.1.1 | |
1.1.1-M4 | |
1.1.1-M3 | |
1.1.1-M2 | |
1.1.1-M1 | |
1.1.0.1 | |
1.1.0 | |
1.1.0-M4 | |
1.1.0-M3 | |
1.1.0-M2 | |
1.1.0-M1 | |
1.0.5.4 | |
1.0.5.3 | |
1.0.5.2 | |
1.0.5.1 | |
1.0.5 | |
1.0.5-M4 | |
1.0.5-M3 | |
1.0.5-M2 | |
1.0.5-M1 | |
1.0.4.1 | |
1.0.4 | |
1.0.3.3 | |
1.0.3.2 | |
1.0.3.1 | |
1.0.3 | |
) | |
RESET_FREQUENCIES=( "100" ) | |
for SNAPPY_VERSION in ${SNAPPY_VERSIONS[@]} | |
do | |
for RESET_FREQUENCY in ${RESET_FREQUENCIES[@]} | |
do | |
export SNAPPY_VERSION | |
size=$(sbt run | grep 'SIZE' | cut -d'=' -f2) | |
echo "$SNAPPY_VERSION $size" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment