From d04c932b33c8565ca49e7b4dafcd4cc944707878 Mon Sep 17 00:00:00 2001 From: esquizo Date: Tue, 19 May 2026 13:43:07 -0300 Subject: Adicionado perf pra validar performance do sistema de fĂ­sica MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libphysics/test/Makefile | 5 ++++- libphysics/test/perf.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 libphysics/test/perf.c diff --git a/libphysics/test/Makefile b/libphysics/test/Makefile index a628f6b..46320e8 100644 --- a/libphysics/test/Makefile +++ b/libphysics/test/Makefile @@ -1,7 +1,7 @@ CFLAGS=-I../../include -g LDFLAGS=-L../ -lphysics `pkg-config --libs sdl3` -lm -all: vis +all: vis perf clean: rm -f vis @@ -10,6 +10,9 @@ clean: vis: ../libphysics.a vis.o $(CC) $^ $(LDFLAGS) -o $@ +perf: ../libphysics.a perf.o + $(CC) $^ $(LDFLAGS) -o $@ + %.o: %.c $(CC) $< $(CFLAGS) -c -o $@ diff --git a/libphysics/test/perf.c b/libphysics/test/perf.c new file mode 100644 index 0000000..67999be --- /dev/null +++ b/libphysics/test/perf.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include + +#define SBODY 2048 +#define FLOAT_RAND (2 * (rand() / (float)RAND_MAX) - 1) + +int +main() +{ + for(int i = 0; i < SBODY; i++) { + BodyID b = phxnew(BTYPE_AABB); + assert(b != -1); + + phxsetpos(b, rand() % 800, rand() % 600); + phxsetsize(b, 5.0, 5.0); + phxapplyaccel(b, (float[]){ 50000 * FLOAT_RAND, 50000 * FLOAT_RAND }); + } + + phxsetmap(8, 8, (int[]) { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 0, 1, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 1, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 0, + 0, 0, 1, 0, 0, 0, 1, 0, + }); + + phxtick(10.0); + + return 0; +} -- cgit v1.2.3