MCPcopy Create free account
hub / github.com/PlatformLab/NanoLog / arrayPush

Function arrayPush

runtime/Perf.cc:573–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

571}
572
573double arrayPush() {
574 const int count = 1000000;
575 char *baseBuffer = static_cast<char*>(malloc(count*4*sizeof(uint64_t)));
576 char *buffer = baseBuffer;
577
578 uint64_t start = Cycles::rdtsc();
579 for (int i = 0; i < count; ++i) {
580 *reinterpret_cast<uint64_t*>(buffer) = 1;
581 buffer += sizeof(uint64_t);
582
583 *reinterpret_cast<uint64_t*>(buffer ) = 2;
584 buffer += sizeof(uint64_t);
585
586 *reinterpret_cast<uint64_t*>(buffer) = 3;
587 buffer += sizeof(uint64_t);
588
589 *reinterpret_cast<uint64_t*>(buffer) = 4;
590 buffer += sizeof(uint64_t);
591 }
592 uint64_t stop = Cycles::rdtsc();
593
594 free(baseBuffer);
595 return Cycles::toSeconds(stop - start)/count;
596}
597
598double arrayStructCast()
599{

Callers

nothing calls this directly

Calls 1

rdtscFunction · 0.85

Tested by

no test coverage detected