From 8388e0dfea4ae0d80e51368acd12685c740c5bb5 Mon Sep 17 00:00:00 2001 From: Jordi Vilalta Prat Date: Tue, 12 Oct 2010 02:18:11 +0000 Subject: JANITORAL: Clean trailing whitespaces. svn-id: r53160 --- backends/platform/psp/tests.cpp | 248 ++++++++++++++++++++-------------------- 1 file changed, 124 insertions(+), 124 deletions(-) (limited to 'backends/platform/psp/tests.cpp') diff --git a/backends/platform/psp/tests.cpp b/backends/platform/psp/tests.cpp index f65c13ae83..4064ee1d98 100644 --- a/backends/platform/psp/tests.cpp +++ b/backends/platform/psp/tests.cpp @@ -23,13 +23,13 @@ * */ -// PSP speed and unit tests. Activate in tests.h -// You may also want to build without any engines. - +// PSP speed and unit tests. Activate in tests.h +// You may also want to build without any engines. + #include "backends/platform/psp/tests.h" -#if defined (PSP_ENABLE_UNIT_TESTS) || defined (PSP_ENABLE_SPEED_TESTS) - +#if defined (PSP_ENABLE_UNIT_TESTS) || defined (PSP_ENABLE_SPEED_TESTS) + #include "common/scummsys.h" #include #include @@ -49,16 +49,16 @@ #define UNCACHED(x) ((byte *)(((uint32)(x)) | 0x40000000)) /* make an uncached access */ #define CACHED(x) ((byte *)(((uint32)(x)) & 0xBFFFFFFF)) /* make an uncached access into a cached one */ - + //#define __PSP_DEBUG_FUNCS__ //#define __PSP_DEBUG_PRINT__ - + // Results: (333Mhz/222Mhz) // Getting a tick: 1-2 us // Getting a time structure: 9/14us // ie. using a tick and just dividing by 1000 saves us time. - -#include "backends/platform/psp/trace.h" + +#include "backends/platform/psp/trace.h" class PspSpeedTests { public: @@ -67,11 +67,11 @@ public: void seekSpeed(); void msReadSpeed(); void threadFunctionsSpeed(); - void semaphoreSpeed(); + void semaphoreSpeed(); static int threadFunc(SceSize args, void *argp); void semaphoreManyThreadSpeed(); void fastCopySpeed(); - + private: enum { MEMCPY_BUFFER_SIZE = 8192 @@ -95,16 +95,16 @@ void PspSpeedTests::tickSpeed() { uint32 currentTicks1[2]; uint32 currentTicks2[2]; - + sceRtcGetCurrentTick((u64 *)currentTicks1); sceRtcGetCurrentTick((u64 *)currentTicks2); PSP_INFO_PRINT("current tick[%x %x][%u %u]\n", currentTicks1[0], currentTicks1[1], currentTicks1[0], currentTicks1[1]); PSP_INFO_PRINT("current tick[%x %x][%u %u]\n", currentTicks2[0], currentTicks2[1], currentTicks2[0], currentTicks2[1]); - + pspTime time; sceRtcSetTick(&time, (u64 *)currentTicks2); - PSP_INFO_PRINT("current tick in time, year[%d] month[%d] day[%d] hour[%d] minutes[%d] seconds[%d] us[%d]\n", time.year, time.month, time.day, time.hour, time.minutes, time.seconds, time.microseconds); - + PSP_INFO_PRINT("current tick in time, year[%d] month[%d] day[%d] hour[%d] minutes[%d] seconds[%d] us[%d]\n", time.year, time.month, time.day, time.hour, time.minutes, time.seconds, time.microseconds); + pspTime time1; pspTime time2; sceRtcGetCurrentClockLocalTime(&time1); @@ -119,7 +119,7 @@ void PspSpeedTests::getMicrosSpeed() { time2 = PspRtc::instance().getMicros(); time3 = PspRtc::instance().getMicros(); time4 = PspRtc::instance().getMicros(); - + PSP_INFO_PRINT("getMicros() times: %d, %d, %d\n", time4-time3, time3-time2, time2-time1); } @@ -128,8 +128,8 @@ void PspSpeedTests::readAndTime(uint32 bytes, char *buffer, FILE *file) { // test minimal read fread(buffer, bytes, 1, file); uint32 time2 = PspRtc::instance().getMicros(); - - PSP_INFO_PRINT("Reading %d byte takes %dus\n", bytes, time2-time1); + + PSP_INFO_PRINT("Reading %d byte takes %dus\n", bytes, time2-time1); } /* @@ -158,7 +158,7 @@ void PspSpeedTests::msReadSpeed() { file = fopen("ms0:/psp/music/track1.mp3", "r"); char *buffer = (char *)malloc(2 * 1024 * 1024); - + readAndTime(1, buffer, file); readAndTime(10, buffer, file); readAndTime(50, buffer, file); @@ -170,32 +170,32 @@ void PspSpeedTests::msReadSpeed() { readAndTime(6000, buffer, file); readAndTime(7000, buffer, file); readAndTime(8000, buffer, file); - readAndTime(9000, buffer, file); + readAndTime(9000, buffer, file); readAndTime(10000, buffer, file); readAndTime(30000, buffer, file); readAndTime(50000, buffer, file); readAndTime(80000, buffer, file); readAndTime(100000, buffer, file); - + fclose(file); - free(buffer); + free(buffer); } - + void PspSpeedTests::seekAndTime(int bytes, int origin, FILE *file) { char buffer[1000]; - + uint32 time1 = PspRtc::instance().getMicros(); // test minimal read fseek(file, bytes, origin); uint32 time2 = PspRtc::instance().getMicros(); - + PSP_INFO_PRINT("Seeking %d byte from %d took %dus\n", bytes, origin, time2-time1); time1 = PspRtc::instance().getMicros(); // test minimal read fread(buffer, 1000, 1, file); time2 = PspRtc::instance().getMicros(); - + PSP_INFO_PRINT("Reading 1000 bytes took %dus\n", time2-time1); } @@ -246,9 +246,9 @@ int PspSpeedTests::getThreadIdSpeed() { uint32 time1 = PspRtc::instance().getMicros(); int threadId = sceKernelGetThreadId(); uint32 time2 = PspRtc::instance().getMicros(); - + PSP_INFO_PRINT("Getting thread ID %d took %dus\n", threadId, time2-time1); - + return threadId; } @@ -257,7 +257,7 @@ void PspSpeedTests::getPrioritySpeed() { uint32 time1 = PspRtc::instance().getMicros(); int priority = sceKernelGetThreadCurrentPriority(); uint32 time2 = PspRtc::instance().getMicros(); - + PSP_INFO_PRINT("Getting thread priority %d took %dus\n", priority, time2-time1); } @@ -266,7 +266,7 @@ void PspSpeedTests::changePrioritySpeed(int id, int priority) { uint32 time1 = PspRtc::instance().getMicros(); sceKernelChangeThreadPriority(id, priority); uint32 time2 = PspRtc::instance().getMicros(); - + PSP_INFO_PRINT("Changing thread priority to %d for id %d took %dus\n", priority, id, time2-time1); } @@ -280,53 +280,53 @@ void PspSpeedTests::threadFunctionsSpeed() { changePrioritySpeed(id, 30); changePrioritySpeed(id, 35); changePrioritySpeed(id, 25); - + // test context switch time for (int i=0; i<10; i++) { uint time1 = PspRtc::instance().getMicros(); PspThread::delayMicros(0); uint time2 = PspRtc::instance().getMicros(); - PSP_INFO_PRINT("poll %d. context switch Time = %dus\n", i, time2-time1); // 10-15us - } + PSP_INFO_PRINT("poll %d. context switch Time = %dus\n", i, time2-time1); // 10-15us + } } - -void PspSpeedTests::semaphoreSpeed() { + +void PspSpeedTests::semaphoreSpeed() { PspSemaphore sem(1); - + uint32 time1 = PspRtc::instance().getMicros(); - + sem.take(); - + uint32 time2 = PspRtc::instance().getMicros(); - + PSP_INFO_PRINT("taking semaphore took %d us\n", time2-time1); // 10us - + uint32 time3 = PspRtc::instance().getMicros(); - + sem.give(); - + uint32 time4 = PspRtc::instance().getMicros(); PSP_INFO_PRINT("releasing semaphore took %d us\n", time4-time3); //10us-55us } int PspSpeedTests::threadFunc(SceSize args, void *argp) { PSP_INFO_PRINT("thread %x created.\n", sceKernelGetThreadId()); - + _sem.take(); - + PSP_INFO_PRINT("grabbed semaphore. Quitting thread\n"); - + return 0; } -void PspSpeedTests::semaphoreManyThreadSpeed() { - +void PspSpeedTests::semaphoreManyThreadSpeed() { + // create 4 threads for (int i=0; i<4; i++) { int thid = sceKernelCreateThread("my_thread", PspSpeedTests::threadFunc, 0x18, 0x10000, THREAD_ATTR_USER, NULL); sceKernelStartThread(thid, 0, 0); } - + PSP_INFO_PRINT("main thread. created threads\n"); uint32 threads = _sem.numOfWaitingThreads(); @@ -334,10 +334,10 @@ void PspSpeedTests::semaphoreManyThreadSpeed() { threads = _sem.numOfWaitingThreads(); PSP_INFO_PRINT("main thread: waiting threads[%d]\n", threads); } - + PSP_INFO_PRINT("main: semaphore value[%d]\n", _sem.getValue()); PSP_INFO_PRINT("main thread: waiting threads[%d]\n", _sem.numOfWaitingThreads()); - + _sem.give(4); } @@ -346,31 +346,31 @@ void PspSpeedTests::fastCopySpecificSize(byte *dst, byte *src, uint32 bytes) { uint32 fastcopyTime, memcpyTime; const int iterations = 2000; int intc; - + intc = pspSdkDisableInterrupts(); - + time1 = PspRtc::instance().getMicros(); for (int i=0; i 0) { if ((int)wrStream->write(index, curLength) != curLength) { PSP_ERROR("couldn't write %d bytes\n", curLength); @@ -595,22 +595,22 @@ bool PspUnitTests::testFileSystem() { PSP_ERROR("couldn't write %d bytes\n", curLength); return false; } - + delete wrStream; - + PSP_INFO_PRINT("reading...\n"); - + rdStream = file.createReadStream(); if (!rdStream) { PSP_ERROR("%s couldn't be created.\n", path); return false; } - + // seek to beginning if (!rdStream->seek(0, SEEK_SET)) { PSP_ERROR("couldn't seek to the beginning after writing the file\n"); return false; - } + } // read the contents char *readBuffer = new char[BufSize + 4]; @@ -619,96 +619,96 @@ bool PspUnitTests::testFileSystem() { while (rdStream->read(index, 100) == 100) { index += 100; } - + if (!rdStream->eos()) { PSP_ERROR("didn't find EOS at end of stream\n"); - return false; + return false; } - + // compare for (i=0; i<(int)BufSize; i++) if (buffer[i] != readBuffer[i]) { PSP_ERROR("reading/writing mistake at %x. Got %x instead of %x\n", i, readBuffer[i], buffer[i]); return false; } - + // Check for exceeding limit for (i=0; i<4; i++) { if (readBuffer[BufSize + i]) { PSP_ERROR("read exceeded limits. %d = %x\n", BufSize + i, readBuffer[BufSize + i]); } - } - + } + delete rdStream; - + PSP_INFO_PRINT("writing...\n"); - + wrStream = file.createWriteStream(); if (!wrStream) { PSP_ERROR("%s couldn't be created.\n", path); return false; } - + const char *phrase = "Jello is really fabulous"; uint32 phraseLen = strlen(phrase); - + int ret; if ((ret = wrStream->write(phrase, phraseLen)) != (int)phraseLen) { PSP_ERROR("couldn't write phrase. Got %d instead of %d\n", ret, phraseLen); return false; } - + PSP_INFO_PRINT("reading...\n"); - + delete wrStream; rdStream = file.createReadStream(); if (!rdStream) { PSP_ERROR("%s couldn't be created.\n", path); return false; } - + char *readPhrase = new char[phraseLen + 2]; memset(readPhrase, 0, phraseLen + 2); - + if ((ret = rdStream->read(readPhrase, phraseLen) != phraseLen)) { PSP_ERROR("read error on phrase. Got %d instead of %d\n", ret, phraseLen); return false; } - + for (i=0; i<(int)phraseLen; i++) { if (readPhrase[i] != phrase[i]) { PSP_ERROR("bad read/write in phrase. At %d, %x != %x\n", i, readPhrase[i], phrase[i]); return false; } - } - + } + // check for exceeding if (readPhrase[i] != 0) { PSP_ERROR("found excessive copy in phrase. %c at %d\n", readPhrase[i], i); return false; } - + PSP_INFO_PRINT("trying to read end...\n"); - + // seek to end if (!rdStream->seek(0, SEEK_END)) { PSP_ERROR("couldn't seek to end for append\n"); return false; }; - + // try to read if (rdStream->read(readPhrase, 2) || !rdStream->eos()) { PSP_ERROR("was able to read at end of file\n"); return false; } - + PSP_INFO_PRINT("ok\n"); return true; } void psp_tests() { PSP_INFO_PRINT("in tests\n"); - + #ifdef PSP_ENABLE_SPEED_TESTS // Speed tests PspSpeedTests speedTests; @@ -718,18 +718,18 @@ void psp_tests() { speedTests.seekSpeed(); speedTests.msReadSpeed(); speedTests.threadFunctionsSpeed(); - speedTests.semaphoreSpeed(); + speedTests.semaphoreSpeed(); speedTests.semaphoreManyThreadSpeed(); speedTests.fastCopySpeed(); -#endif - +#endif + #ifdef PSP_ENABLE_UNIT_TESTS // Unit tests PspUnitTests unitTests; - + //unitTests.testFastCopy(); unitTests.testFileSystem(); -#endif -} +#endif +} -#endif /* (PSP_ENABLE_UNIT_TESTS) || defined (PSP_ENABLE_SPEED_TESTS) */ \ No newline at end of file +#endif /* (PSP_ENABLE_UNIT_TESTS) || defined (PSP_ENABLE_SPEED_TESTS) */ -- cgit v1.2.3