increase cache of stringified longs
This should improve the csv generation a little bit.
This commit is contained in:
@@ -1,22 +1,22 @@
|
|||||||
package org.lucares.recommind.logs;
|
package org.lucares.recommind.logs;
|
||||||
|
|
||||||
public class LongUtils {
|
public class LongUtils {
|
||||||
|
|
||||||
private static final int INT_TO_STRING_CACHE_SIZE= 1000;
|
private static final int INT_TO_STRING_CACHE_SIZE = 10_000;
|
||||||
private static final String[] INT_TO_STRING;
|
private static final String[] INT_TO_STRING;
|
||||||
static {
|
static {
|
||||||
|
|
||||||
INT_TO_STRING = new String[INT_TO_STRING_CACHE_SIZE];
|
INT_TO_STRING = new String[INT_TO_STRING_CACHE_SIZE];
|
||||||
|
|
||||||
for (int i = 0; i < INT_TO_STRING_CACHE_SIZE; i++){
|
for (int i = 0; i < INT_TO_STRING_CACHE_SIZE; i++) {
|
||||||
INT_TO_STRING[i] = String.valueOf(i);
|
INT_TO_STRING[i] = String.valueOf(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String longToString(final long value){
|
public static String longToString(final long value) {
|
||||||
// using pre-generated strings reduces memory allocation by up to 25%
|
// using pre-generated strings reduces memory allocation by up to 25%
|
||||||
|
|
||||||
if (value < INT_TO_STRING_CACHE_SIZE){
|
if (value < INT_TO_STRING_CACHE_SIZE) {
|
||||||
return INT_TO_STRING[(int) value];
|
return INT_TO_STRING[(int) value];
|
||||||
}
|
}
|
||||||
return String.valueOf(value);
|
return String.valueOf(value);
|
||||||
|
|||||||
Reference in New Issue
Block a user