* 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 */
| 692 | * average time per cpyByte copy |
| 693 | */ |
| 694 | double 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 | |
| 718 | double manualCopyCached1() |
| 719 | { |
no test coverage detected