Add memcpy perf test

This commit is contained in:
Mathieu Maret 2021-09-15 21:53:08 +02:00
parent 10d42721e9
commit 57bae864f8
1 changed files with 28 additions and 2 deletions

View File

@ -11,6 +11,29 @@
#include "synchro.h"
#include "time.h"
void testMemcpyPerf()
{
struct test_struct {
char data[4096];
};
// instantiate 2 structs. for our purposes, we don't care what data is in
// there. set them to `volatile` so the compiler won't optimize away what we
// do with them
volatile struct test_struct dest, source;
printf("Test Memcpy perf\n");
// run through powers-of-two memcpy's, printing stats for each test
for (size_t len = 1; len <= sizeof(dest); len <<= 1) {
uint32_t start = read_cycle_counter(); // << Start count
memcpy((void *)&dest, (void *)&source, len);
uint32_t stop = read_cycle_counter(); // << Stop count
// print out the cycles consumed
printf("len = %d, %d %d cyccnt = %d, cycles/byte = %d\n", (uint32_t)len, stop, start,
stop - start, (stop - start) / len);
}
}
void testPhymem(void)
{
printf("Testing memory PHY\n");
@ -47,7 +70,8 @@ void testPhymem(void)
assert(freePageStatFree == freePageStatBegin);
assert(usedPageStatFree == usedPageStatBegin);
assertmsg((page = (struct phyMemDesc *)allocPhyPage(1)) != NULL, "Cannot allocate memory\n");
assertmsg((page = (struct phyMemDesc *)allocPhyPage(1)) != NULL,
"Cannot allocate memory\n");
unrefPhyPage((ulong)page);
}
@ -135,7 +159,8 @@ static void testPaging(void)
}
printf("%d pages freed\n", freeCount);
assertmsg((page = (struct phyMemDesc *)allocPhyPage(1)) != NULL, "Cannot allocate memory\n");
assertmsg((page = (struct phyMemDesc *)allocPhyPage(1)) != NULL,
"Cannot allocate memory\n");
unrefPhyPage((ulong)page);
}
@ -313,6 +338,7 @@ void testKthread()
void run_test(void)
{
testMemcpyPerf();
{
int test = 1000;
long long int test64 = 0x100000000;