Memory stick read speed is very low

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Noko
Posts: 23
Joined: Sat Sep 06, 2008 8:35 pm

Memory stick read speed is very low

Post by Noko »

Here's the program I'm using to read file from memory stick:

Code: Select all

#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&#40;"IOTEST", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER | THREAD_ATTR_VFPU&#41;;

#define printf	pspDebugScreenPrintf

int main&#40;void&#41;&#123;
	struct timeval now,then;
	char buffer&#91;0x400&#93;;
	SceIoStat stats;
	SceUID f;

	pspDebugScreenInit&#40;&#41;;

	f=sceIoOpen&#40;"bgm15.ogg",PSP_O_RDONLY,0777&#41;;
	gettimeofday&#40;&now, NULL&#41;;
	while&#40;sceIoRead&#40;f,buffer,sizeof&#40;buffer&#41;&#41;&#41;
		;
	gettimeofday&#40;&then, NULL&#41;;
	sceIoClose&#40;f&#41;;
	
	sceIoGetstat&#40;"bgm15.ogg",&stats&#41;;
	
	printf&#40;"took %ldms to read %lldKB",
		&#40;then.tv_sec-now.tv_sec&#41;*1000+&#40;then.tv_usec-now.tv_usec&#41;/1000,stats.st_size/0x400&#41;;
	
	while&#40;1&#41;
		;
&#125;
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?
Noko
Posts: 23
Joined: Sat Sep 06, 2008 8:35 pm

Post by Noko »

Ah, nevermind, I found the solution. Using larger buffer improves speed dramatically.
willow :--)
Posts: 107
Joined: Sat Jan 13, 2007 11:50 am

Post by willow :--) »

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.
Post Reply