mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
#144 replace Double[] with double[]
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.core.OS;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ArrayTest {
|
||||
// don't use Double[] as it uses ~3.5x the memory of a double[]
|
||||
@Test
|
||||
public void testDoubleArray() throws IOException {
|
||||
File file = new File(OS.getTarget() + "/testDoubleArray-" + System.nanoTime());
|
||||
ChronicleMap<Long, double[]> writeMap = ChronicleMapBuilder
|
||||
.of(Long.class, double[].class)
|
||||
.entries(1_000)
|
||||
.averageValue(new double[150])
|
||||
.createPersistedTo(file);
|
||||
double a[] = {2D};
|
||||
writeMap.put(1L, a);
|
||||
|
||||
//read
|
||||
ChronicleMap<Long, double[]> readMap =
|
||||
ChronicleMapBuilder.of(Long.class, double[].class)
|
||||
.averageValue(new double[150])
|
||||
.createPersistedTo(file);
|
||||
double b[] = readMap.get(1L);
|
||||
}
|
||||
|
||||
// don't use Long[] as it uses ~3.5x the memory of a long[]
|
||||
@Test
|
||||
public void testLongArray() throws IOException {
|
||||
File file = new File(OS.getTarget() + "/testLongArray-" + System.nanoTime());
|
||||
ChronicleMap<Long, long[]> writeMap = ChronicleMapBuilder
|
||||
.of(Long.class, long[].class)
|
||||
.entries(1_000)
|
||||
.averageValue(new long[150])
|
||||
.createPersistedTo(file);
|
||||
long a[] = {2};
|
||||
writeMap.put(1L, a);
|
||||
|
||||
//read
|
||||
ChronicleMap<Long, long[]> readMap =
|
||||
ChronicleMapBuilder.of(Long.class, long[].class)
|
||||
.averageValue(new long[150])
|
||||
.createPersistedTo(file);
|
||||
long b[] = readMap.get(1L);
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package net.openhft.lang.values;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import net.openhft.chronicle.map.ChronicleMap;
|
||||
import net.openhft.chronicle.map.ChronicleMapBuilder;
|
||||
|
||||
public class ArrayTest {
|
||||
@Test
|
||||
public void test() throws IOException {
|
||||
String TMP = System.getProperty("java.io.tmpdir");
|
||||
File file = new File(TMP + "/pf-PosistionsAndClose-" + System.nanoTime());
|
||||
ChronicleMap<Long, Double[]> writeMap = ChronicleMapBuilder
|
||||
.of(Long.class, Double[].class)
|
||||
.entries(1_000)
|
||||
.averageValue(new Double[150])
|
||||
.createPersistedTo(file);
|
||||
Double a[]={2D};
|
||||
writeMap.put(1L,a);
|
||||
|
||||
//read
|
||||
ChronicleMap<Long, Double[]> readMap =
|
||||
ChronicleMapBuilder.of(Long.class, Double[].class)
|
||||
.averageValue(new Double[150])
|
||||
.createPersistedTo(file);
|
||||
Double b[] = readMap.get(1L);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user