Skip to content

Instantly share code, notes, and snippets.

@vyazelenko
Created October 30, 2013 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vyazelenko/7224987 to your computer and use it in GitHub Desktop.
Save vyazelenko/7224987 to your computer and use it in GitHub Desktop.
TestConstructor.java
package com.vyazelenko.blog.copyobject;
import com.vyazelenko.blog.copyobject.primitives.clone.CloneCopy;
import com.vyazelenko.blog.copyobject.primitives.constructor.ConstructorCopy;
import java.util.ArrayList;
import java.util.List;
public class TestConstructor {
public static List<Copyable> results;
public static void main(String[] args) {
runTest();
}
public static void runTest() {
warmup();
test();
}
private static void warmup() {
doCopy(500_000, "warmup");
}
private static void doCopy(int iterations, String message) {
results = new ArrayList<>(iterations);
System.out.println("\n\n>>> In " + message);
for (int i = 0; i < iterations; i++) {
results.add(callCopy());
}
System.out.println("<<< " + message + " completed");
}
private int resultsHash() {
return results.hashCode();
}
private static Copyable callCopy() {
return ConstructorCopy.INSTANCE.copy();
}
private static void test() {
doCopy(10_000_000, "test");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment