add benchmark code

This commit is contained in:
Milang 2020-02-18 10:29:59 +01:00
parent 2fb9be227d
commit e842b6376e
2 changed files with 55 additions and 41 deletions

View File

@ -60,7 +60,7 @@ INCLUDE := -I include
# Libraries. Add one -l option for each library you are using, and also
# suitable -L options if you have library files in custom folders. To use
# fxlib, add libfx.a to the project directory and use "-L . -lfx".
LIBS :=
LIBS := -lprof
# Base linker flags for the fxSDK, you usually want to keep these.
LDFLAGS_FX := -T fx9860g.ld -lgint-fx $(LIBS) -lgint-fx -lgcc

View File

@ -3,50 +3,64 @@
#include <gint/bfile.h>
#include "Chip8.h"
#include "opcode.h"
// libprof tests
#include <libprof.h>
#include <gint/std/stdio.h>
struct Chip8 chip8 = {
.PC = 0x200,
.memory= { //bitmap for the fonts
0xF0, 0x90, 0x90, 0x90, 0xF0, //0
0x20, 0x60, 0x20, 0x20, 0x70, //1
0xF0, 0x10, 0xF0, 0x80, 0xF0, //2
0xF0, 0x10, 0xF0, 0x10, 0xF0, //3
0x90, 0x90, 0xF0, 0x10, 0x10, //4
0xF0, 0x80, 0xF0, 0x10, 0xF0, //5
0xF0, 0x80, 0xF0, 0x90, 0xF0, //6
0xF0, 0x10, 0x20, 0x40, 0x40, //7
0xF0, 0x90, 0xF0, 0x90, 0xF0, //8
0xF0, 0x90, 0xF0, 0x10, 0xF0, //9
0xF0, 0x90, 0xF0, 0x90, 0x90, //A
0xE0, 0x90, 0xE0, 0x90, 0xE0, //B
0xF0, 0x80, 0x80, 0x80, 0xF0, //C
0xE0, 0x90, 0x90, 0x90, 0xE0, //D
0xF0, 0x80, 0xF0, 0x80, 0xF0, //E
0xF0, 0x80, 0xF0, 0x80, 0x80 //F
}};
.PC = 0x200,
.memory= { //bitmap for the fonts
0xF0, 0x90, 0x90, 0x90, 0xF0, //0
0x20, 0x60, 0x20, 0x20, 0x70, //1
0xF0, 0x10, 0xF0, 0x80, 0xF0, //2
0xF0, 0x10, 0xF0, 0x10, 0xF0, //3
0x90, 0x90, 0xF0, 0x10, 0x10, //4
0xF0, 0x80, 0xF0, 0x10, 0xF0, //5
0xF0, 0x80, 0xF0, 0x90, 0xF0, //6
0xF0, 0x10, 0x20, 0x40, 0x40, //7
0xF0, 0x90, 0xF0, 0x90, 0xF0, //8
0xF0, 0x90, 0xF0, 0x10, 0xF0, //9
0xF0, 0x90, 0xF0, 0x90, 0x90, //A
0xE0, 0x90, 0xE0, 0x90, 0xE0, //B
0xF0, 0x80, 0x80, 0x80, 0xF0, //C
0xE0, 0x90, 0x90, 0x90, 0xE0, //D
0xF0, 0x80, 0xF0, 0x80, 0xF0, //E
0xF0, 0x80, 0xF0, 0x80, 0x80 //F
}
};
int main(void)
{
int file_handler;
uint16_t const * pathname = u"\\\\fls0\\PUZZLE.ch8";
int file_handler;
uint16_t const * pathname = u"\\\\fls0\\PONG.ch8";
dclear(C_BLACK);
dupdate();
file_handler = BFile_Open(pathname, BFile_ReadOnly);
/* if(file_handler > 0)
{
dtext(1,1,"reading", C_BLACK, C_WHITE);
dupdate();
getkey();
}
if(BFile_Read(file_handler, &chip8.memory[0x200], 3000,-1) > 0)
{
dtext(1,1,"reading", C_BLACK, C_WHITE);
dupdate();
getkey();
}*/
BFile_Read(file_handler, &chip8.memory[0x200], 264,-1);
while(1)
{
execute();
}
return 1;
file_handler = BFile_Open(pathname, BFile_ReadOnly);
BFile_Read(file_handler, &chip8.memory[0x200], 264,-1);
// prof init
char time[7];
prof_init(1, 0);
prof_clear(0);
int i=0;
while(1)
{
dprint(1, 50, C_WHITE, C_BLACK, "%s", time);
prof_enter(0);
execute();
prof_leave(0);
i++;
if (!(i%=256))
{ // test sur 256 actions -> moyenne
snprintf(time, sizeof(time), "%d", (prof_time(0) >> 8));
prof_clear(0);
}
dprint(1, 50, C_WHITE, C_BLACK, "%s", time);
}
return 1;
}