TestConstructor.java
This file contains 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
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