Hello.
I have recently been experimenting with files.
I use ps2link on the ps2 side and ps2client on the pc side (linux).
So far I have only been reading files from host:.
When I try to read a file byte by byte with fgetc
and immediately print it out with printf i notice that the characters are incoming about 1 each 0,5 second.
And even if i remove the printf outputing each character as it's read from the file it still takes a couple of seconds to read the file.
And the file is only 33bytes in size.
On the other hand the elf file which is much larger get's loaded almost immediately when I execute it.
Is there a faster way to read files?
Is there any more information I should provide or is this a known issue?
Thanks
File reading from host extremely slow?
The problem is that the communication between the PS2 and your PC is taking alot longer than the time just read 1 byte from a file. This is a common problem since commucating over the network (I/O in general) is alot slower than your CPU.
For instance if communication takes C ms (milliseconds) and reading 1 byte from PC HDD takes R ms, if you read B bytes one at a time, the total read time will be: C*R*B ms.
If you instead just read all the B bytes in one go, you get C + (R*B).
As an example: C = 500, R = 1, B = 50.
One byte at a time: 500 * 1 * 50 = 25000 ms
All bytes at once: 500 + 1 * 50 = 550 ms
So basicly when dealing with I/O (like the network) you want to read as much data as possible each time you access it.
For instance if communication takes C ms (milliseconds) and reading 1 byte from PC HDD takes R ms, if you read B bytes one at a time, the total read time will be: C*R*B ms.
If you instead just read all the B bytes in one go, you get C + (R*B).
As an example: C = 500, R = 1, B = 50.
One byte at a time: 500 * 1 * 50 = 25000 ms
All bytes at once: 500 + 1 * 50 = 550 ms
So basicly when dealing with I/O (like the network) you want to read as much data as possible each time you access it.