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

Function manualCopy

runtime/Perf.cc:694–716  ·  view source on GitHub ↗

* Measure the cost of copying cpyBytes from cold/hot source/destinations * * \param cpySize * Size of the copy * \param coldSrc * if false, source will be fixed; otherwise random * \param coldDst * if false, destination will be fixed; otherwise random * \return * average time per cpyByte copy */

Source from the content-addressed store, hash-verified

692 * average time per cpyByte copy
693 */
694double manualCopy(int cpySize, bool coldSrc, bool coldDst) {
695 int count = 1000000;
696 uint32_t src[count], dst[count];
697 int bufSize = 1000000000; // 1GB buffer
698 char *buf = static_cast<char*>(malloc(bufSize));
699
700 uint32_t bound = (bufSize - cpySize);
701 for (int i = 0; i < count; i++) {
702 src[i] = (coldSrc) ? (rand() % bound) : 0;
703 dst[i] = (coldDst) ? (rand() % bound) : 0;
704 }
705
706 uint64_t start = Cycles::rdtsc();
707 for (int i = 0; i < count; i++) {
708 for (int j = 0; j < cpySize; ++j) {
709 *(buf + dst[i]) = *(buf + src[i]);
710 }
711 }
712 uint64_t stop = Cycles::rdtsc();
713
714 free(buf);
715 return Cycles::toSeconds(stop - start)/(count);
716}
717
718double manualCopyCached1()
719{

Callers 2

manualCopyCached1Function · 0.85
manualCopyCached10Function · 0.85

Calls 1

rdtscFunction · 0.85

Tested by

no test coverage detected