查了算法,整合了一个算圆周率的小程序,您看一下:
// PSP PI
//
// Reference: 
// http://www.codecodex.com/wiki/Calculate_digits_of_pi#C
// https://github.com/OPL3ChipFan/sdlpal/tree/psp
// https://en.wikibooks.org/wiki/PSP_Programming/General/Hello_World
#include <stdio.h>
#include "SDL/SDL.h"
#include <pspkernel.h>
#include <pspctrl.h>
#include <SDL_thread.h>
#include <pspdisplay.h>
#include <pspsdk.h>
#include <psppower.h>
#include <pspthreadman.h>
#include <stdlib.h>
#include <time.h>
#define DEFAULTARG 60000
#define SCALE 10000  
#define ARRINIT 2000 
#define printf pspDebugScreenPrintf
PSP_MODULE_INFO("PI Test", PSP_MODULE_USER, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
PSP_HEAP_SIZE_MAX();
int PSP_exit_callback(int arg1, int arg2, void* common)
{
	exit(0);
	return 0;
}
int PSP_exit_callback_thread(SceSize args, void* argp)
{
	int cbid;
	cbid = sceKernelCreateCallback("Exit Callback", PSP_exit_callback, NULL);
	sceKernelRegisterExitCallback(cbid);
	sceKernelSleepThreadCB();
	return 0;
}
int PSP_exit_setup_callbacks(void)
{
	int thid = 0;
	thid = sceKernelCreateThread("update_thread", PSP_exit_callback_thread, 0x11, 0xFA0, 0, 0);
	if (thid >= 0)
		sceKernelStartThread(thid, 0, 0);
	return thid;
}
void pi_digits(int digits) {
	int carry = 0;
	int arr[digits + 1];
	for (int i = 0; i <= digits; ++i)
		arr[i] = ARRINIT;
	for (int i = digits; i > 0; i -= 14) {
		int sum = 0;
		for (int j = i; j > 0; --j) {
			sum = sum * j + SCALE * arr[j];
			arr[j] = sum % (j * 2 - 1);
			sum /= j * 2 - 1;
		}
		printf("%04d", carry + sum / SCALE);
		carry = sum % SCALE;
	}
}
int main(int argc, char **argv)
{
	int n = argc == 2 ? atoi(argv[1]) : DEFAULTARG;
	time_t start, end;
	pspDebugScreenInit();
	PSP_exit_setup_callbacks();
	//
	// Register sceKernelExitGame() to be called when we exit 
	//
	atexit(sceKernelExitGame);
	scePowerSetClockFrequency(222, 222, 111);
	start = time(NULL);
	printf("START!\n");
	pi_digits(n);
	printf("\nEND!\n");
	end = time(NULL);
	printf("222MHz = %ld\n", (end - start));
	scePowerSetClockFrequency(333, 333, 166);
	start = time(NULL);
	printf("START!\n");
	pi_digits(n);
	printf("\nEND!\n");
	end = time(NULL);
	printf("333MHz = %ld\n", (end - start));
	sleep(500);
    return 0;
}
在PSV上,两段计时分别是36秒和24秒。看来虽然涉及了printf函数的因素,但整体感觉还是有参考价值的。