The core of my test program (full thing: https://github.com/davidgiven/cowgol/bl ... dspeed.cow) is:
Code: Select all
var fd: uint8 := file_openin(&arg);
print("File handle: 0x");
var bytes: uint32 := 0;
var before: uint32 := gettime();
while file_eof(fd) == 0 loop
var c: int8 := file_getchar(fd);
bytes := bytes + 1;
var time: uint32 := gettime() - before;
print("Total bytes: 0x"); print_hex_i32(bytes); print_newline();
print("Total time: 0x"); print_hex_i32(time); print_newline();
(I can't do 32-bit division yet so that's left as an exercise for the reader.)
On ADFS and DFS I'm getting about 700 bytes per second. On VDFS in b-em it's about 1000 bytes per second. Bear in mind that Cowgol compiles into real (if not great) machine code, so there should be minimal language overhead.
So why is this so slow?
It occurs to me that I know nothing about how big the disk buffers are --- this is on a BBC Master. Does anyone know? Are they big enough to store an entire sector at a time? Would I get any benefit to doing user-space buffering and OSGBPB rather than OSBGET/OSBPUT (which is effectively the CP/M model)? Or is this just how fast a 2MHz 6502 is?
OSFILE whole-file-at-a-time gets several kilobytes a second. Of course, that's not a different problem because it doesn't have to indirect via a buffer and can just slap the data straight into memory from the NMI handler, but still...