28
28
public class ExampleSimpleWriteReadMain {
29
29
public static void main (String ... args ) throws IOException {
30
30
final long runs = 1000 * 1000000L ;
31
+ final int batchSize = 10 ;
32
+ System .out .printf ("Messages to write %,d in batches of %,d%n" , runs , batchSize );
31
33
long start = System .nanoTime ();
32
34
final String basePath = System .getProperty ("java.io.tmpdir" ) + "/ExampleSimpleWriteReadMain" ;
33
35
ChronicleTools .deleteOnExit (basePath );
@@ -39,11 +41,13 @@ public void run() {
39
41
IndexedChronicle ic = new IndexedChronicle (basePath );
40
42
ic .useUnsafe (true ); // for benchmarks
41
43
Excerpt excerpt = ic .createExcerpt ();
42
- for (long i = 1 ; i <= runs ; i ++) {
43
- excerpt .startExcerpt (13 );
44
- excerpt .writeUnsignedByte ('M' ); // message type
45
- excerpt .writeLong (i ); // e.g. time stamp
46
- excerpt .writeFloat (i );
44
+ for (long i = 1 ; i <= runs ; i += batchSize ) {
45
+ excerpt .startExcerpt (13 * batchSize );
46
+ for (int k = 0 ; k < batchSize ; k ++) {
47
+ excerpt .writeUnsignedByte ('M' ); // message type
48
+ excerpt .writeLong (i ); // e.g. time stamp
49
+ excerpt .writeFloat (i );
50
+ }
47
51
excerpt .finish ();
48
52
}
49
53
ic .close ();
@@ -58,16 +62,18 @@ public void run() {
58
62
Excerpt excerpt = ic .createExcerpt ();
59
63
int blocks = 1000000 ;
60
64
for (long j = 0 ; j < runs ; j += blocks ) {
61
- for (long i = j + 1 ; i <= j + blocks ; i ++ ) {
65
+ for (long i = j + 1 ; i <= j + blocks ; i += batchSize ) {
62
66
while (!excerpt .nextIndex ()) {
63
67
// busy wait
64
68
}
65
- char ch = (char ) excerpt .readUnsignedByte ();
66
- long l = excerpt .readLong ();
67
- float d = excerpt .readFloat ();
68
- assert ch == 'M' ;
69
- assert l == i ;
70
- assert d == (float ) i ;
69
+ for (int k = 0 ; k < batchSize ; k ++) {
70
+ char ch = (char ) excerpt .readUnsignedByte ();
71
+ long l = excerpt .readLong ();
72
+ float d = excerpt .readFloat ();
73
+ assert ch == 'M' ;
74
+ assert l == i ;
75
+ assert d == (float ) i ;
76
+ }
71
77
excerpt .finish ();
72
78
}
73
79
if (((j + blocks ) % 100000000 ) == 0 ) {
@@ -284,4 +290,207 @@ public void run() {
284
290
... Took 1228.14 to write and read 19,900,000,000 entries
285
291
... Took 1235.11 to write and read 20,000,000,000 entries
286
292
Took 1247.07 to write and read 20,000,000,000 entries
293
+
294
+ batchSize=10
295
+ ... Took 1.48 to write and read 100,000,000 entries
296
+ ... Took 3.47 to write and read 200,000,000 entries
297
+ ... Took 5.22 to write and read 300,000,000 entries
298
+ ... Took 7.85 to write and read 400,000,000 entries
299
+ ... Took 9.81 to write and read 500,000,000 entries
300
+ ... Took 12.14 to write and read 600,000,000 entries
301
+ ... Took 14.15 to write and read 700,000,000 entries
302
+ ... Took 16.39 to write and read 800,000,000 entries
303
+ ... Took 18.52 to write and read 900,000,000 entries
304
+ ... Took 20.29 to write and read 1,000,000,000 entries
305
+ ... Took 22.52 to write and read 1,100,000,000 entries
306
+ ... Took 24.66 to write and read 1,200,000,000 entries
307
+ ... Took 26.19 to write and read 1,300,000,000 entries
308
+ ... Took 27.89 to write and read 1,400,000,000 entries
309
+ ... Took 29.68 to write and read 1,500,000,000 entries
310
+ ... Took 31.55 to write and read 1,600,000,000 entries
311
+ ... Took 40.31 to write and read 1,700,000,000 entries
312
+ ... Took 42.34 to write and read 1,800,000,000 entries
313
+ ... Took 44.47 to write and read 1,900,000,000 entries
314
+ ... Took 46.65 to write and read 2,000,000,000 entries
315
+ ... Took 48.80 to write and read 2,100,000,000 entries
316
+ ... Took 51.05 to write and read 2,200,000,000 entries
317
+ ... Took 53.15 to write and read 2,300,000,000 entries
318
+ ... Took 55.44 to write and read 2,400,000,000 entries
319
+ ... Took 60.76 to write and read 2,500,000,000 entries
320
+ ... Took 62.61 to write and read 2,600,000,000 entries
321
+ ... Took 64.90 to write and read 2,700,000,000 entries
322
+ ... Took 67.01 to write and read 2,800,000,000 entries
323
+ ... Took 69.20 to write and read 2,900,000,000 entries
324
+ ... Took 71.48 to write and read 3,000,000,000 entries
325
+ ... Took 73.55 to write and read 3,100,000,000 entries
326
+ ... Took 75.86 to write and read 3,200,000,000 entries
327
+ ... Took 81.97 to write and read 3,300,000,000 entries
328
+ ... Took 83.75 to write and read 3,400,000,000 entries
329
+ ... Took 86.02 to write and read 3,500,000,000 entries
330
+ ... Took 88.19 to write and read 3,600,000,000 entries
331
+ ... Took 90.43 to write and read 3,700,000,000 entries
332
+ ... Took 92.68 to write and read 3,800,000,000 entries
333
+ ... Took 94.94 to write and read 3,900,000,000 entries
334
+ ... Took 97.27 to write and read 4,000,000,000 entries
335
+ ... Took 102.70 to write and read 4,100,000,000 entries
336
+ ... Took 104.75 to write and read 4,200,000,000 entries
337
+ ... Took 107.00 to write and read 4,300,000,000 entries
338
+ ... Took 109.26 to write and read 4,400,000,000 entries
339
+ ... Took 111.47 to write and read 4,500,000,000 entries
340
+ ... Took 113.67 to write and read 4,600,000,000 entries
341
+ ... Took 115.79 to write and read 4,700,000,000 entries
342
+ ... Took 118.06 to write and read 4,800,000,000 entries
343
+ ... Took 121.48 to write and read 4,900,000,000 entries
344
+ ... Took 125.64 to write and read 5,000,000,000 entries
345
+ ... Took 127.85 to write and read 5,100,000,000 entries
346
+ ... Took 130.01 to write and read 5,200,000,000 entries
347
+ ... Took 132.20 to write and read 5,300,000,000 entries
348
+ ... Took 134.46 to write and read 5,400,000,000 entries
349
+ ... Took 136.95 to write and read 5,500,000,000 entries
350
+ ... Took 139.28 to write and read 5,600,000,000 entries
351
+ ... Took 141.44 to write and read 5,700,000,000 entries
352
+ ... Took 146.98 to write and read 5,800,000,000 entries
353
+ ... Took 149.00 to write and read 5,900,000,000 entries
354
+ ... Took 151.29 to write and read 6,000,000,000 entries
355
+ ... Took 153.45 to write and read 6,100,000,000 entries
356
+ ... Took 155.78 to write and read 6,200,000,000 entries
357
+ ... Took 157.90 to write and read 6,300,000,000 entries
358
+ ... Took 160.19 to write and read 6,400,000,000 entries
359
+ ... Took 162.36 to write and read 6,500,000,000 entries
360
+ ... Took 167.97 to write and read 6,600,000,000 entries
361
+ ... Took 170.02 to write and read 6,700,000,000 entries
362
+ ... Took 172.25 to write and read 6,800,000,000 entries
363
+ ... Took 174.41 to write and read 6,900,000,000 entries
364
+ ... Took 176.64 to write and read 7,000,000,000 entries
365
+ ... Took 178.94 to write and read 7,100,000,000 entries
366
+ ... Took 181.21 to write and read 7,200,000,000 entries
367
+ ... Took 183.34 to write and read 7,300,000,000 entries
368
+ ... Took 189.11 to write and read 7,400,000,000 entries
369
+ ... Took 191.17 to write and read 7,500,000,000 entries
370
+ ... Took 193.18 to write and read 7,600,000,000 entries
371
+ ... Took 195.60 to write and read 7,700,000,000 entries
372
+ ... Took 197.80 to write and read 7,800,000,000 entries
373
+ ... Took 200.07 to write and read 7,900,000,000 entries
374
+ ... Took 202.29 to write and read 8,000,000,000 entries
375
+ ... Took 204.50 to write and read 8,100,000,000 entries
376
+ ... Took 210.27 to write and read 8,200,000,000 entries
377
+ ... Took 212.10 to write and read 8,300,000,000 entries
378
+ ... Took 214.28 to write and read 8,400,000,000 entries
379
+ ... Took 216.64 to write and read 8,500,000,000 entries
380
+ ... Took 218.78 to write and read 8,600,000,000 entries
381
+ ... Took 221.04 to write and read 8,700,000,000 entries
382
+ ... Took 223.17 to write and read 8,800,000,000 entries
383
+ ... Took 225.26 to write and read 8,900,000,000 entries
384
+ ... Took 231.22 to write and read 9,000,000,000 entries
385
+ ... Took 233.21 to write and read 9,100,000,000 entries
386
+ ... Took 235.35 to write and read 9,200,000,000 entries
387
+ ... Took 237.71 to write and read 9,300,000,000 entries
388
+ ... Took 239.96 to write and read 9,400,000,000 entries
389
+ ... Took 242.16 to write and read 9,500,000,000 entries
390
+ ... Took 244.36 to write and read 9,600,000,000 entries
391
+ ... Took 246.65 to write and read 9,700,000,000 entries
392
+ ... Took 252.19 to write and read 9,800,000,000 entries
393
+ ... Took 254.25 to write and read 9,900,000,000 entries
394
+ ... Took 256.60 to write and read 10,000,000,000 entries
395
+ ... Took 258.87 to write and read 10,100,000,000 entries
396
+ ... Took 261.18 to write and read 10,200,000,000 entries
397
+ ... Took 263.39 to write and read 10,300,000,000 entries
398
+ ... Took 265.58 to write and read 10,400,000,000 entries
399
+ ... Took 267.90 to write and read 10,500,000,000 entries
400
+ ... Took 273.56 to write and read 10,600,000,000 entries
401
+ ... Took 275.71 to write and read 10,700,000,000 entries
402
+ ... Took 277.81 to write and read 10,800,000,000 entries
403
+ ... Took 280.15 to write and read 10,900,000,000 entries
404
+ ... Took 282.36 to write and read 11,000,000,000 entries
405
+ ... Took 284.60 to write and read 11,100,000,000 entries
406
+ ... Took 286.80 to write and read 11,200,000,000 entries
407
+ ... Took 288.94 to write and read 11,300,000,000 entries
408
+ ... Took 294.63 to write and read 11,400,000,000 entries
409
+ ... Took 297.04 to write and read 11,500,000,000 entries
410
+ ... Took 299.30 to write and read 11,600,000,000 entries
411
+ ... Took 301.50 to write and read 11,700,000,000 entries
412
+ ... Took 303.75 to write and read 11,800,000,000 entries
413
+ ... Took 306.03 to write and read 11,900,000,000 entries
414
+ ... Took 308.25 to write and read 12,000,000,000 entries
415
+ ... Took 310.40 to write and read 12,100,000,000 entries
416
+ ... Took 315.62 to write and read 12,200,000,000 entries
417
+ ... Took 318.12 to write and read 12,300,000,000 entries
418
+ ... Took 320.36 to write and read 12,400,000,000 entries
419
+ ... Took 322.57 to write and read 12,500,000,000 entries
420
+ ... Took 324.87 to write and read 12,600,000,000 entries
421
+ ... Took 327.11 to write and read 12,700,000,000 entries
422
+ ... Took 329.32 to write and read 12,800,000,000 entries
423
+ ... Took 331.53 to write and read 12,900,000,000 entries
424
+ ... Took 336.56 to write and read 13,000,000,000 entries
425
+ ... Took 339.12 to write and read 13,100,000,000 entries
426
+ ... Took 341.44 to write and read 13,200,000,000 entries
427
+ ... Took 343.63 to write and read 13,300,000,000 entries
428
+ ... Took 345.89 to write and read 13,400,000,000 entries
429
+ ... Took 348.05 to write and read 13,500,000,000 entries
430
+ ... Took 350.41 to write and read 13,600,000,000 entries
431
+ ... Took 352.79 to write and read 13,700,000,000 entries
432
+ ... Took 357.53 to write and read 13,800,000,000 entries
433
+ ... Took 360.26 to write and read 13,900,000,000 entries
434
+ ... Took 362.39 to write and read 14,000,000,000 entries
435
+ ... Took 364.58 to write and read 14,100,000,000 entries
436
+ ... Took 366.91 to write and read 14,200,000,000 entries
437
+ ... Took 368.97 to write and read 14,300,000,000 entries
438
+ ... Took 371.33 to write and read 14,400,000,000 entries
439
+ ... Took 373.50 to write and read 14,500,000,000 entries
440
+ ... Took 378.20 to write and read 14,600,000,000 entries
441
+ ... Took 381.01 to write and read 14,700,000,000 entries
442
+ ... Took 383.23 to write and read 14,800,000,000 entries
443
+ ... Took 385.43 to write and read 14,900,000,000 entries
444
+ ... Took 387.73 to write and read 15,000,000,000 entries
445
+ ... Took 389.90 to write and read 15,100,000,000 entries
446
+ ... Took 392.28 to write and read 15,200,000,000 entries
447
+ ... Took 394.56 to write and read 15,300,000,000 entries
448
+ ... Took 399.47 to write and read 15,400,000,000 entries
449
+ ... Took 401.99 to write and read 15,500,000,000 entries
450
+ ... Took 404.23 to write and read 15,600,000,000 entries
451
+ ... Took 406.49 to write and read 15,700,000,000 entries
452
+ ... Took 408.85 to write and read 15,800,000,000 entries
453
+ ... Took 410.97 to write and read 15,900,000,000 entries
454
+ ... Took 413.25 to write and read 16,000,000,000 entries
455
+ ... Took 415.41 to write and read 16,100,000,000 entries
456
+ ... Took 420.64 to write and read 16,200,000,000 entries
457
+ ... Took 423.19 to write and read 16,300,000,000 entries
458
+ ... Took 425.52 to write and read 16,400,000,000 entries
459
+ ... Took 427.71 to write and read 16,500,000,000 entries
460
+ ... Took 430.04 to write and read 16,600,000,000 entries
461
+ ... Took 432.21 to write and read 16,700,000,000 entries
462
+ ... Took 434.53 to write and read 16,800,000,000 entries
463
+ ... Took 436.74 to write and read 16,900,000,000 entries
464
+ ... Took 441.75 to write and read 17,000,000,000 entries
465
+ ... Took 444.73 to write and read 17,100,000,000 entries
466
+ ... Took 446.80 to write and read 17,200,000,000 entries
467
+ ... Took 449.03 to write and read 17,300,000,000 entries
468
+ ... Took 451.40 to write and read 17,400,000,000 entries
469
+ ... Took 453.55 to write and read 17,500,000,000 entries
470
+ ... Took 455.81 to write and read 17,600,000,000 entries
471
+ ... Took 458.02 to write and read 17,700,000,000 entries
472
+ ... Took 463.34 to write and read 17,800,000,000 entries
473
+ ... Took 466.19 to write and read 17,900,000,000 entries
474
+ ... Took 468.43 to write and read 18,000,000,000 entries
475
+ ... Took 470.58 to write and read 18,100,000,000 entries
476
+ ... Took 472.76 to write and read 18,200,000,000 entries
477
+ ... Took 475.12 to write and read 18,300,000,000 entries
478
+ ... Took 477.42 to write and read 18,400,000,000 entries
479
+ ... Took 479.68 to write and read 18,500,000,000 entries
480
+ ... Took 484.76 to write and read 18,600,000,000 entries
481
+ ... Took 487.17 to write and read 18,700,000,000 entries
482
+ ... Took 489.41 to write and read 18,800,000,000 entries
483
+ ... Took 491.74 to write and read 18,900,000,000 entries
484
+ ... Took 493.85 to write and read 19,000,000,000 entries
485
+ ... Took 496.16 to write and read 19,100,000,000 entries
486
+ ... Took 498.49 to write and read 19,200,000,000 entries
487
+ ... Took 500.84 to write and read 19,300,000,000 entries
488
+ ... Took 506.05 to write and read 19,400,000,000 entries
489
+ ... Took 508.80 to write and read 19,500,000,000 entries
490
+ ... Took 510.96 to write and read 19,600,000,000 entries
491
+ ... Took 513.25 to write and read 19,700,000,000 entries
492
+ ... Took 515.60 to write and read 19,800,000,000 entries
493
+ ... Took 517.88 to write and read 19,900,000,000 entries
494
+ ... Took 520.11 to write and read 20,000,000,000 entries
495
+ Took 525.09 to write and read 20,000,000,000 entries
287
496
*/
0 commit comments