A lot? Especially the Primary Key I think there are many ints and longs When API communication is sandwiched, it will become a String
So the conversion is String.valueOf
or ʻObject.toString`?
package test;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* test
*
* @author me
*
*/
public class Test1 {
/**
* main
* @param args
*/
public static void main(String[] args) {
System.out.println("-------Start measurement-------");
Long start1 = System.currentTimeMillis();
run1();
Long end1 = System.currentTimeMillis();
System.out.println("String.valueOf() : " + (end1 - start1) + "ms");
Long start2 = System.currentTimeMillis();
run2();
Long end2 = System.currentTimeMillis();
System.out.println("Object.toString() : " + (end2 - start2) + "ms");
System.out.println("-------End of measurement-------");
}
/**
* {@link String#valueOf()}
*/
private static void run1() {
IntStream.range(0, 5000000).boxed().map(String::valueOf).collect(Collectors.toList());
}
/**
* {@link Object#toString()}
*/
private static void run2() {
IntStream.range(0, 5000000).boxed().map(Object::toString).collect(Collectors.toList());
}
}
-------Start measurement-------
String.valueOf() : 2024ms
Object.toString() : 904ms
-------End of measurement-------
Yeah, that's different ...
Well, ʻObject.toString` can't be used for primitive types, and it feels like ...
By the way
package test;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* test
*
* @author me
*
*/
public class TestT {
/**
* main
* @param args
*/
public static void main(String[] args) {
System.out.println("-------Start measurement-------");
Long start1 = System.currentTimeMillis();
run1();
Long end1 = System.currentTimeMillis();
System.out.println((end1 - start1) + "ms");
System.out.println("-------End of measurement-------");
}
/**
*Is this good?
*/
private static void run1() {
IntStream.range(0, 5000000).boxed().map(v -> v + "").collect(Collectors.toList());
}
}
-------Start measurement-------
3021ms
-------End of measurement-------
It's no good w