Play- icon indicating copy to clipboard operation
Play- copied to clipboard

add an IO Port to get the host clock value

Open bigianb opened this issue 6 years ago • 3 comments

Something like this would allow us to profile test scripts without needing to use the CD clock hack (that is a bit useless in any case from the EE as it goes via an RPC channel which takes an indeterminate amount of time)

Note ... just for discussion at the moment. Not even tested and would need something similar on the IOP side too.

bigianb avatar Aug 30 '19 16:08 bigianb

Looking good! Did you test it with an executable generated from PS2SDK?

jpd002 avatar Sep 12 '19 19:09 jpd002

Looking good! Did you test it with an executable generated from PS2SDK?

yes ... but it's a very trivial test and so not in github yet. Just a POC really. It writes to stdout so the result is in the log file.

#include <tamtypes.h>
#include <stdio.h>

static void Kputc(u8 c) {
    while (*((u32*)0x1000f130) & 0x8000) { __asm__ ("nop\nnop\nnop\n"); }
    
	*((u8*)0x1000f180) = c;
}

static void Kputs(u8 *s) {
	while (*s != 0) {
		Kputc(*s++);
	}
}

int main()
{
	u32 startTime, endTime, clocksPerSec;
	u8 buf[256];
	int i;

	Kputs("Loop test\n");

	startTime = *((u32*)0x10001900);

	for (i=0; i<0x10000; ++i){
		__asm__ ("nop\nnop\nnop\n");
	}

	endTime = *((u32*)0x10001900);
	clocksPerSec = *((u32*)0x10001904);

	sprintf(buf, "start=%d, end=%d, clocksPerSec=%d\n", startTime, endTime, clocksPerSec);
	Kputs(buf);

    return 0;
}

bigianb avatar Sep 12 '19 22:09 bigianb

I've pushed the test code up to a repo:

https://github.com/bigianb/ps2-speedtests

bigianb avatar Jan 14 '21 23:01 bigianb