Update examples
This commit is contained in:
@ -31,7 +31,7 @@ public class Main {
|
||||
return String.format("Object %s", o);
|
||||
}
|
||||
|
||||
private static long[] runNTimes(int numberOfRuns, Object[] toTest, Consumer<? super Object> code) {
|
||||
private static <T> long[] runNTimes(int numberOfRuns, T[] toTest, Consumer<T> code) {
|
||||
long runs[] = new long[numberOfRuns];
|
||||
for (int i = 0; i < numberOfRuns; i++) {
|
||||
long startTime = System.nanoTime();
|
||||
@ -52,7 +52,7 @@ public class Main {
|
||||
.orWhen(Byte.class::isInstance, b -> "byte " + b)
|
||||
.orWhen(Double.class::isInstance, d -> "double " + d)
|
||||
.orWhen(String.class::isInstance, s -> "String " + s)
|
||||
.otherwise(o -> "Object " + o);
|
||||
.otherwise(o -> String.format("Object %s", o));
|
||||
|
||||
final int nRuns = 100000;
|
||||
final Statistics formatObjectStats = Statistics.from(runNTimes(nRuns, toTest, Main::formatObject));
|
||||
|
Reference in New Issue
Block a user