11/*
2- * Copyright 2013 Peter Lawrey
2+ * Copyright 2014 Higher Frequency Trading
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -115,13 +115,10 @@ public void testAppend() throws IOException {
115115
116116 @ Test
117117 public void testAppend4 () throws IOException , InterruptedException {
118- final int RUNS = 20000 ;
118+ final int RUNS = 500000 ; // increase to 25 million for a proper test. Can be 50% faster.
119119 String baseDir = System .getProperty ("java.io.tmpdir" ) + "/testAppend4" ;
120- VanillaChronicleConfig config = new VanillaChronicleConfig ();
121- config .defaultMessageSize (128 );
122- // config.indexBlockSize(1024);
123- // config.dataBlockSize(1024);
124120 long start = System .nanoTime ();
121+ VanillaChronicleConfig config = new VanillaChronicleConfig ().defaultMessageSize (64 );
125122 final VanillaChronicle chronicle = new VanillaChronicle (baseDir , config );
126123 chronicle .clear ();
127124 ExecutorService es = Executors .newFixedThreadPool (N_THREADS );
@@ -134,9 +131,9 @@ public void run() {
134131 ExcerptAppender appender = chronicle .createAppender ();
135132 for (int i = 0 ; i < RUNS ; i ++) {
136133 appender .startExcerpt ();
137- appender .append (finalT ).append ("/ " ).append (i ).append ('\n' );
134+ appender .appendDateMillis ( System . currentTimeMillis ()). append (" - " ). append ( finalT ).append (" / " ).append (i ).append ('\n' );
138135 appender .finish ();
139- Thread .yield ();
136+ // Thread.yield();
140137 }
141138 } catch (Exception e ) {
142139 e .printStackTrace ();
@@ -145,11 +142,11 @@ public void run() {
145142 });
146143 }
147144 es .shutdown ();
148- es .awaitTermination (2 , TimeUnit .SECONDS );
145+ es .awaitTermination (30 , TimeUnit .SECONDS );
149146 long time = System .nanoTime () - start ;
150147 chronicle .close ();
151148 chronicle .clear ();
152- System .out .printf ("Took an average of %.1f us per entry %n" , time / 1e3 / (RUNS * N_THREADS ));
149+ System .out .printf ("Throughput was %.0f per milli-second %n" , 1e6 * (RUNS * N_THREADS ) / time );
153150 }
154151
155152 @ Test
0 commit comments