mirror of https://github.com/mgba-emu/mgba.git
Vita: Add supporting framework for mgba-perf
This commit is contained in:
parent
9c7548855e
commit
6599e2173c
|
@ -28,6 +28,7 @@ set(OS_LIB -lvita2d -l${M_LIBRARY}
|
|||
-lScePower_stub
|
||||
-lSceSysmodule_stub
|
||||
-lSceTouch_stub)
|
||||
set(OS_LIB ${OS_LIB} PARENT_SCOPE)
|
||||
set(OBJCOPY_CMD ${OBJCOPY} -I binary -O elf32-littlearm -B arm)
|
||||
|
||||
list(APPEND GUI_SRC ${CMAKE_CURRENT_SOURCE_DIR}/gui-font.c)
|
||||
|
@ -61,5 +62,29 @@ vita_create_vpk(${BINARY_NAME}.vpk MGBA00001 ${BINARY_NAME}.self
|
|||
FILE ${CMAKE_CURRENT_SOURCE_DIR}/startup.png sce_sys/livearea/contents/startup.png
|
||||
FILE ${CMAKE_CURRENT_BINARY_DIR}/template.xml sce_sys/livearea/contents/template.xml)
|
||||
|
||||
if(BUILD_PERF)
|
||||
add_executable(perf-main.elf perf.c)
|
||||
set_target_properties(perf-main.elf PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
|
||||
target_link_libraries(perf-main.elf ${OS_LIB})
|
||||
|
||||
vita_create_self(perf.bin ../${BINARY_NAME}-perf)
|
||||
vita_create_self(perf-main.self perf-main.elf)
|
||||
|
||||
vita_create_vpk(${BINARY_NAME}-perf.vpk MGBA00002 perf-main.self
|
||||
NAME "${PROJECT_NAME} Perf Tester"
|
||||
FILE ${CMAKE_CURRENT_BINARY_DIR}/perf.bin perf.bin
|
||||
FILE ${CMAKE_CURRENT_SOURCE_DIR}/icon0.png sce_sys/icon0.png
|
||||
FILE ${CMAKE_CURRENT_SOURCE_DIR}/pic0.png sce_sys/pic0.png
|
||||
FILE ${CMAKE_CURRENT_SOURCE_DIR}/bg.png sce_sys/livearea/contents/bg.png
|
||||
FILE ${CMAKE_CURRENT_SOURCE_DIR}/startup.png sce_sys/livearea/contents/startup.png
|
||||
FILE ${CMAKE_CURRENT_BINARY_DIR}/template.xml sce_sys/livearea/contents/template.xml)
|
||||
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/perf.bin
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/perf-start.sh
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}-perf.vpk
|
||||
DESTINATION . COMPONENT ${BINARY_NAME}-perf)
|
||||
endif()
|
||||
|
||||
install(TARGETS ${BINARY_NAME}.elf DESTINATION . COMPONENT ${BINARY_NAME}-dbg)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.vpk DESTINATION . COMPONENT ${BINARY_NAME}-psp2)
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/sh
|
||||
IP=$1
|
||||
shift
|
||||
|
||||
# Kill any previous session
|
||||
echo | nc $IP 7215
|
||||
echo | nc $IP 7216
|
||||
|
||||
curl -sT perf.bin ftp://$IP:1337/ux0:app/MGBA00002/
|
||||
echo launch MGBA00002 | nc $IP 1338 > /dev/null
|
||||
|
||||
sleep 2
|
||||
|
||||
(for ARG in $@; do
|
||||
echo $ARG
|
||||
done; echo) | nc $IP 7215
|
|
@ -0,0 +1,57 @@
|
|||
/* Copyright (c) 2013-2020 Jeffrey Pfau
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include <mgba-util/socket.h>
|
||||
|
||||
#include <psp2/appmgr.h>
|
||||
#include <psp2/kernel/processmgr.h>
|
||||
#include <psp2/kernel/threadmgr.h>
|
||||
|
||||
#define MAX_ARGS 19
|
||||
|
||||
|
||||
void connectServer(char* args[]) {
|
||||
Socket server = SocketOpenTCP(7215, NULL);
|
||||
if (SOCKET_FAILED(server)) {
|
||||
return;
|
||||
}
|
||||
if (SOCKET_FAILED(SocketListen(server, 0))) {
|
||||
SocketClose(server);
|
||||
return;
|
||||
}
|
||||
Socket conn = SocketAccept(server, NULL);
|
||||
if (SOCKET_FAILED(conn)) {
|
||||
SocketClose(server);
|
||||
return;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
ssize_t len;
|
||||
char arg[1024];
|
||||
while (i < MAX_ARGS && (len = SocketRecv(conn, arg, sizeof(arg) - 1)) > 0) {
|
||||
arg[len] = '\0';
|
||||
char* tok;
|
||||
for (tok = strtok(arg, "\n"); tok && i < MAX_ARGS; ++i) {
|
||||
args[i] = strdup(tok);
|
||||
tok = strtok(NULL, "\n");
|
||||
}
|
||||
if (arg[len - 1] == '\n') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SocketClose(conn);
|
||||
SocketClose(server);
|
||||
}
|
||||
|
||||
int main() {
|
||||
char* args[MAX_ARGS + 1] = { 0 };
|
||||
SocketSubsystemInit();
|
||||
connectServer(args);
|
||||
SocketSubsystemDeinit();
|
||||
sceAppMgrLoadExec("app0:/perf.bin", args, NULL);
|
||||
sceKernelExitProcess(0);
|
||||
return 0;
|
||||
}
|
|
@ -72,18 +72,20 @@ class GameClockTest(PerfTest):
|
|||
class PerfServer(object):
|
||||
ITERATIONS_PER_INSTANCE = 50
|
||||
|
||||
def __init__(self, address, command=None):
|
||||
def __init__(self, address, root='/', command=None):
|
||||
s = address.rsplit(':', 1)
|
||||
if len(s) == 1:
|
||||
self.address = (s[0], 7216)
|
||||
else:
|
||||
self.address = (s[0], s[1])
|
||||
self.command = None
|
||||
if command:
|
||||
self.command = shlex.split(command)
|
||||
self.iterations = self.ITERATIONS_PER_INSTANCE
|
||||
self.socket = None
|
||||
self.results = []
|
||||
self.reader = None
|
||||
self.root = root
|
||||
|
||||
def _start(self, test):
|
||||
if self.command:
|
||||
|
@ -108,7 +110,7 @@ class PerfServer(object):
|
|||
def run(self, test):
|
||||
if not self.socket:
|
||||
self._start(test)
|
||||
self.socket.send(os.path.join("/perfroms", test.rom).encode("utf-8"))
|
||||
self.socket.send(os.path.join(self.root, test.rom).encode("utf-8"))
|
||||
self.results.append(next(self.reader))
|
||||
self.iterations -= 1
|
||||
if self.iterations == 0:
|
||||
|
@ -178,6 +180,7 @@ if __name__ == '__main__':
|
|||
parser.add_argument('-s', '--server', metavar='ADDRESS', help='run on server')
|
||||
parser.add_argument('-S', '--server-command', metavar='COMMAND', help='command to launch server')
|
||||
parser.add_argument('-o', '--out', metavar='FILE', help='output file path')
|
||||
parser.add_argument('-r', '--root', metavar='PATH', type=str, default='/perfroms', help='root path for server mode')
|
||||
parser.add_argument('directory', help='directory containing ROM files')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
@ -189,9 +192,9 @@ if __name__ == '__main__':
|
|||
s = Suite(args.directory, wall=args.wall_time, game=args.game_frames, renderer=renderer)
|
||||
if args.server:
|
||||
if args.server_command:
|
||||
server = PerfServer(args.server, args.server_command)
|
||||
server = PerfServer(args.server, args.root, args.server_command)
|
||||
else:
|
||||
server = PerfServer(args.server)
|
||||
server = PerfServer(args.server, args.root)
|
||||
s.set_server(server)
|
||||
s.collect_tests()
|
||||
results = s.run()
|
||||
|
|
Loading…
Reference in New Issue