Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.enragedginger.stephenerialization.benching;
 
 import java.io.File;
Base class for Stephenerialization benchmarking.

Author(s):
Stephen Hopper
public abstract class BaseStephenerializationBenchmarker {
	private static final Random randy = new Random();
	private static final String QUOTE = "\"";
	private static final String SEPARATOR = "\",\"";
	protected abstract BasicPojo createNewPojo();
	protected abstract String getTempObjectOutputStreamFile();
	protected void fillPojo(BasicPojo pojo) {
	}
	protected void runTest(String[] argsthrows IOException {
		int groupSize = Integer.parseInt(args[0]);
		File tempOutputFile = new File(getTempObjectOutputStreamFile());
		ObjectOutputStream streamer = new ObjectOutputStream(new FileOutputStream(tempOutputFile));
		BasicPojo[] pojos = new BasicPojo[groupSize];
		for (int i = 0; i < groupSizei++) {
			fillPojo(pojo);
			pojos[i] = pojo;
		}
		long startMilliTime = System.currentTimeMillis();
		long startNanoTime = System.nanoTime();
		for (BasicPojo pojo : pojos) {
			streamer.writeObject(pojo);
		}
		streamer.flush();
		streamer.close();
		long endMilliTime = System.currentTimeMillis();
		long endNanoTime = System.nanoTime();
		tempOutputFile.delete();
		long totalMilliTime = endMilliTime - startMilliTime;
		long totalNanoTime = endNanoTime - startNanoTime;
		..println( + groupSize +  + totalMilliTime +  + totalNanoTime + );
	}
New to GrepCode? Check out our FAQ X