 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Noko
Joined: 06 Sep 2008 Posts: 23
|
Posted: Sat Sep 06, 2008 10:15 pm Post subject: Memory stick read speed is very low |
|
|
Here's the program I'm using to read file from memory stick:
| Code: | #include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <stdlib.h>
#include <string.h>
#include <pspiofilemgr.h>
#include <time.h>
#include <sys/time.h>
#include <pspthreadman.h>
PSP_MODULE_INFO("IOTEST", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
#define printf pspDebugScreenPrintf
int main(void){
struct timeval now,then;
char buffer[0x400];
SceIoStat stats;
SceUID f;
pspDebugScreenInit();
f=sceIoOpen("bgm15.ogg",PSP_O_RDONLY,0777);
gettimeofday(&now, NULL);
while(sceIoRead(f,buffer,sizeof(buffer)))
;
gettimeofday(&then, NULL);
sceIoClose(f);
sceIoGetstat("bgm15.ogg",&stats);
printf("took %ldms to read %lldKB",
(then.tv_sec-now.tv_sec)*1000+(then.tv_usec-now.tv_usec)/1000,stats.st_size/0x400);
while(1)
;
} |
And the output is ``took 3585ms to read 3364KB''. Now when I copy files from memorystick to my hard drive through USB the speed is roughly 5MB/s, 5 times better. Is something wrong with my code/psp, or is this correct behavior? |
|
| Back to top |
|
 |
Noko
Joined: 06 Sep 2008 Posts: 23
|
Posted: Sun Sep 07, 2008 12:51 am Post subject: |
|
|
| Ah, nevermind, I found the solution. Using larger buffer improves speed dramatically. |
|
| Back to top |
|
 |
willow :--)
Joined: 13 Jan 2007 Posts: 126
|
Posted: Mon Sep 08, 2008 12:15 pm Post subject: |
|
|
| Noko wrote: | | Ah, nevermind, I found the solution. Using larger buffer improves speed dramatically. |
Yes. Most of the time, unless your file is really big, you'll want your buffer to be dynamically allocated to be the same size as the file, and read the file in one time. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|