MCPcopy Create free account
hub / github.com/apple/foundationdb / testSerializationSpeed

Function testSerializationSpeed

fdbserver/fdbserver.actor.cpp:375–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373}
374
375void testSerializationSpeed() {
376 double tstart;
377 double build = 0, serialize = 0, deserialize = 0, copy = 0, deallocate = 0;
378 double bytes = 0;
379 double testBegin = timer();
380 for (int a = 0; a < 10000; a++) {
381 {
382 tstart = timer();
383
384 Arena batchArena;
385 VectorRef<CommitTransactionRef> batch;
386 batch.resize(batchArena, 1000);
387 for (int t = 0; t < batch.size(); t++) {
388 CommitTransactionRef& tr = batch[t];
389 tr.read_snapshot = 0;
390 for (int i = 0; i < 2; i++)
391 tr.mutations.push_back_deep(
392 batchArena,
393 MutationRef(MutationRef::SetValue, LiteralStringRef("KeyABCDE"), LiteralStringRef("SomeValu")));
394 tr.mutations.push_back_deep(
395 batchArena,
396 MutationRef(MutationRef::ClearRange, LiteralStringRef("BeginKey"), LiteralStringRef("EndKeyAB")));
397 }
398
399 build += timer() - tstart;
400
401 tstart = timer();
402
403 BinaryWriter wr(IncludeVersion());
404 wr << batch;
405
406 bytes += wr.getLength();
407
408 serialize += timer() - tstart;
409
410 for (int i = 0; i < 1; i++) {
411 tstart = timer();
412 Arena arena;
413 StringRef data(arena, StringRef((const uint8_t*)wr.getData(), wr.getLength()));
414 copy += timer() - tstart;
415
416 tstart = timer();
417 ArenaReader rd(arena, data, IncludeVersion());
418 VectorRef<CommitTransactionRef> batch2;
419 rd >> arena >> batch2;
420
421 deserialize += timer() - tstart;
422 }
423
424 tstart = timer();
425 }
426 deallocate += timer() - tstart;
427 }
428 double elapsed = (timer() - testBegin);
429 printf("Test speed: %0.1f MB/sec (%0.0f/sec)\n", bytes / 1e6 / elapsed, 1000000 / elapsed);
430 printf(" Build: %0.1f MB/sec\n", bytes / 1e6 / build);
431 printf(" Serialize: %0.1f MB/sec\n", bytes / 1e6 / serialize);
432 printf(" Copy: %0.1f MB/sec\n", bytes / 1e6 / copy);

Callers

nothing calls this directly

Calls 10

MutationRefClass · 0.85
IncludeVersionFunction · 0.85
printfFunction · 0.85
getLengthMethod · 0.80
timerFunction · 0.50
StringRefClass · 0.50
resizeMethod · 0.45
sizeMethod · 0.45
push_back_deepMethod · 0.45
getDataMethod · 0.45

Tested by

no test coverage detected