Search in sources :

Example 6 with SnapshotRecord

use of org.apache.geode.internal.cache.snapshot.SnapshotPacket.SnapshotRecord in project geode by apache.

the class GFSnapshotJUnitPerformanceTest method testCopyPerformance.

@Test
public void testCopyPerformance() throws IOException, ClassNotFoundException {
    int count = 100000;
    for (int i = 0; i < 10; i++) {
        writeFile(count, val);
        File tmp = File.createTempFile("snapshot-copy", null);
        tmp.deleteOnExit();
        final SnapshotWriter writer = GFSnapshot.create(tmp, "test");
        long start = System.currentTimeMillis();
        SnapshotIterator<Integer, String> iter = GFSnapshot.read(f);
        try {
            while (iter.hasNext()) {
                Entry<Integer, String> entry = iter.next();
                writer.snapshotEntry(new SnapshotRecord(null, entry));
            }
            writer.snapshotComplete();
            long elapsed = System.currentTimeMillis() - start;
            double rate = 1.0 * count / elapsed;
            System.out.println("rate = " + rate + " entries / ms");
        } finally {
            iter.close();
        }
    }
}
Also used : SnapshotWriter(org.apache.geode.internal.cache.snapshot.GFSnapshot.SnapshotWriter) SnapshotRecord(org.apache.geode.internal.cache.snapshot.SnapshotPacket.SnapshotRecord) File(java.io.File) Test(org.junit.Test) PerformanceTest(org.apache.geode.test.junit.categories.PerformanceTest)

Example 7 with SnapshotRecord

use of org.apache.geode.internal.cache.snapshot.SnapshotPacket.SnapshotRecord in project geode by apache.

the class GFSnapshotJUnitPerformanceTest method testWritePerformance.

@Test
public void testWritePerformance() throws IOException {
    int j = 0;
    while (j++ < 10) {
        long start = System.currentTimeMillis();
        int count = 100000;
        String s = val;
        SnapshotWriter ss = GFSnapshot.create(f, "test");
        try {
            for (int i = 0; i < count; i++) {
                ss.snapshotEntry(new SnapshotRecord(i, s));
            }
        } finally {
            ss.snapshotComplete();
        }
        long elapsed = System.currentTimeMillis() - start;
        double rate = 1000.0 * count / elapsed;
        System.out.println(rate + " write operations / sec");
    }
}
Also used : SnapshotWriter(org.apache.geode.internal.cache.snapshot.GFSnapshot.SnapshotWriter) SnapshotRecord(org.apache.geode.internal.cache.snapshot.SnapshotPacket.SnapshotRecord) Test(org.junit.Test) PerformanceTest(org.apache.geode.test.junit.categories.PerformanceTest)

Example 8 with SnapshotRecord

use of org.apache.geode.internal.cache.snapshot.SnapshotPacket.SnapshotRecord in project geode by apache.

the class GFSnapshotJUnitPerformanceTest method testStreamReadPerformance.

@Test
public void testStreamReadPerformance() throws IOException, ClassNotFoundException {
    writeFile(100000, val);
    int i = 0;
    while (i++ < 10) {
        long start = System.currentTimeMillis();
        int count = 0;
        GFSnapshotImporter in = new GFSnapshotImporter(f);
        SnapshotRecord entry;
        while ((entry = in.readSnapshotRecord()) != null) {
            count++;
        }
        in.close();
        long elapsed = System.currentTimeMillis() - start;
        double rate = 1000.0 * count / elapsed;
        System.out.println(rate + " stream read operations / sec");
    }
}
Also used : GFSnapshotImporter(org.apache.geode.internal.cache.snapshot.GFSnapshot.GFSnapshotImporter) SnapshotRecord(org.apache.geode.internal.cache.snapshot.SnapshotPacket.SnapshotRecord) Test(org.junit.Test) PerformanceTest(org.apache.geode.test.junit.categories.PerformanceTest)

Aggregations

SnapshotRecord (org.apache.geode.internal.cache.snapshot.SnapshotPacket.SnapshotRecord)8 File (java.io.File)3 SnapshotWriter (org.apache.geode.internal.cache.snapshot.GFSnapshot.SnapshotWriter)3 PerformanceTest (org.apache.geode.test.junit.categories.PerformanceTest)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 GFSnapshotImporter (org.apache.geode.internal.cache.snapshot.GFSnapshot.GFSnapshotImporter)2 IntOpenHashSet (it.unimi.dsi.fastutil.ints.IntOpenHashSet)1 LongOpenHashSet (it.unimi.dsi.fastutil.longs.LongOpenHashSet)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 NoSuchElementException (java.util.NoSuchElementException)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 EntryDestroyedException (org.apache.geode.cache.EntryDestroyedException)1 SnapshotIterator (org.apache.geode.cache.snapshot.SnapshotIterator)1