Search in sources :

Example 16 with LapTimer

use of org.trie4j.test.LapTimer in project trie4j by takawitter.

the class AbstractSetWikipediaSerializeTest method test.

@SuppressWarnings("unchecked")
@Test
public void test() throws Exception {
    WikipediaTitles wt = new WikipediaTitles();
    Set<String> set = wt.insertTo(set());
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    LapTimer lt = new LapTimer();
    oos.writeObject(set);
    oos.flush();
    long wd = lt.lapMillis();
    byte[] serialized = baos.toByteArray();
    lt.reset();
    Set<String> t = (Set<String>) new ObjectInputStream(new ByteArrayInputStream(serialized)).readObject();
    long rd = lt.lapMillis();
    long vd = wt.assertAllContains(t);
    System.out.println(String.format("%s%s, size: %d, write(ms): %d, read(ms): %d, verify(ms): %d.", set.getClass().getSimpleName(), "", serialized.length, wd, rd, vd));
}
Also used : Set(java.util.Set) ByteArrayInputStream(java.io.ByteArrayInputStream) WikipediaTitles(org.trie4j.test.WikipediaTitles) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) LapTimer(org.trie4j.test.LapTimer) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Aggregations

LapTimer (org.trie4j.test.LapTimer)16 WikipediaTitles (org.trie4j.test.WikipediaTitles)12 Test (org.junit.Test)8 PrintWriter (java.io.PrintWriter)6 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 Trie (org.trie4j.Trie)4 ObjectInputStream (java.io.ObjectInputStream)3 ObjectOutputStream (java.io.ObjectOutputStream)3 PatriciaTrie (org.trie4j.patricia.PatriciaTrie)3 TailPatriciaTrie (org.trie4j.patricia.TailPatriciaTrie)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Node (org.trie4j.Node)2 NodeVisitor (org.trie4j.NodeVisitor)2 TailLOUDSTrie (org.trie4j.louds.TailLOUDSTrie)2 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 Set (java.util.Set)1 GZIPInputStream (java.util.zip.GZIPInputStream)1