forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Memory stick read speed is very low

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Noko



Joined: 06 Sep 2008
Posts: 23

PostPosted: Sat Sep 06, 2008 10:15 pm    Post subject: Memory stick read speed is very low Reply with quote

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
View user's profile Send private message
Noko



Joined: 06 Sep 2008
Posts: 23

PostPosted: Sun Sep 07, 2008 12:51 am    Post subject: Reply with quote

Ah, nevermind, I found the solution. Using larger buffer improves speed dramatically.
Back to top
View user's profile Send private message
willow :--)



Joined: 13 Jan 2007
Posts: 126

PostPosted: Mon Sep 08, 2008 12:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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