Created
July 13, 2018 07:14
-
-
Save Langerz82/96fcb953c4612d8d6b458ba61843df00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const uint32 testChars = 1024; | |
const uint32 numTests = 50; | |
ByteBuffer buff[numTests]; | |
ByteBuffer buff2[numTests]; | |
UpdateMask updateMask[numTests]; | |
for (int n = 0; n < 10; ++n) | |
{ | |
for (int m = 0; m < numTests; ++m) | |
{ | |
updateMask[m].SetCount(testChars * 8); | |
for (uint32 i = 0; i < testChars; ++i) | |
{ | |
char c = (rand() % 26) + 65; | |
buff[m] << c; | |
buff2[m] << c; | |
} | |
for (uint32 i = 0; i < testChars; ++i) | |
{ | |
char c = (rand() % 26) + 65; | |
for (int k = 0; k < 8; ++k) | |
{ | |
updateMask[m].SetBit((c >> k) & 1); | |
} | |
} | |
} | |
auto start = std::chrono::steady_clock::now(); | |
for (int m = 0; m < numTests; ++m) | |
{ | |
updateMask[m].AppendToPacketOld(&buff[m]); | |
//buff.print_storage(); | |
} | |
float oldTime = (float)std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::steady_clock::now() - start).count(); | |
start = std::chrono::steady_clock::now(); | |
for (int m = 0; m < numTests; ++m) | |
{ | |
updateMask[m].AppendToPacketNew(&buff2[m]); | |
//buff2.print_storage(); | |
} | |
float newTime = (float)std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::steady_clock::now() - start).count(); | |
char buffer[10]; | |
sprintf(buffer, "%.3f%%", (100 - (newTime / oldTime) * 100)); | |
std::cout << "AppendToPacketNew improvement: " << buffer << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment