public static void main(String[] args) throws Exception {
		snzipExecutable = TestUtil.findSnzipExecutable();
		if(snzipExecutable == null) {
			throw new IllegalStateException("No executable snzip file found in bin directory");
		}
	
		testdataDirectory = TestUtil.directoriesToFile("resources", "testdata");
		
		if(!testdataDirectory.exists() || !testdataDirectory.isDirectory() || testdataDirectory.listFiles().length == 0) {
			throw new IllegalStateException("Test data directory \"" + testdataDirectory.getAbsolutePath() + " does not exist, is not a directory or is empty");
		}

		TestUtil.deleteRecursive(new File("tmp"));

		File tmpDirectory = TestUtil.directoriesToFile("tmp", "SnappyEncoderEfficiencyTest");
		
		TestUtil.copyRecursive(testdataDirectory, tmpDirectory);
		
		ProcessBuilder pb = new ProcessBuilder(snzipExecutable, "*");
		pb.directory(tmpDirectory);
		pb.redirectErrorStream(true);
		Process p = pb.start();

		TestUtil.pipe(p.getInputStream(),  System.out);
		int snzReturnCode = p.waitFor();
		if(snzReturnCode != 0) {
			Assert.fail("snzip exited with return code " + snzReturnCode);
		}
		
		System.out.println();
		System.out.println();
		
		for(File org : testdataDirectory.listFiles()) {
			if(org.isFile()) {
				// System.out.println("comparing " + org.getName());
				byte[] originalData = TestUtil.readFully(org);

				int nativeLength = (int)new File(tmpDirectory, org.getName() + ".snz").length();
				double nativeSize = 100. * nativeLength / originalData.length;

				ByteArrayOutputStream jsnappyData = new ByteArrayOutputStream();
				SnzOutputStream sos = new SnzOutputStream(jsnappyData);
				sos.setCompressionEffort(1);
				sos.write(originalData);
				sos.close();
				double javaSize1 = 100. * jsnappyData.toByteArray().length / originalData.length;
				
				jsnappyData = new ByteArrayOutputStream();
				sos = new SnzOutputStream(jsnappyData);
				sos.setCompressionEffort(50);
				sos.write(originalData);
				sos.close();
				double javaSize50 = 100. * jsnappyData.toByteArray().length / originalData.length;
				
				jsnappyData = new ByteArrayOutputStream();
				sos = new SnzOutputStream(jsnappyData);
				sos.setCompressionEffort(100);
				sos.write(originalData);
				sos.close();
				double javaSize100 = 100. * jsnappyData.toByteArray().length / originalData.length;

				System.out.printf("%s: native: %.1f%%, Java: %.1f%% - %.1f%% - %.1f%% %n", org.getName(), nativeSize, javaSize1, javaSize50, javaSize100);
			}
		}
	}