From: Jean-Philippe Bruyère Date: Mon, 2 Sep 2019 03:18:18 +0000 (+0200) Subject: add perf tests X-Git-Tag: v0.1-alpha~62 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=9cc9fbfeb2ff47f2d62ac35dd061b8fbbfda1a4d;p=jp%2Fvkvg.git add perf tests --- diff --git a/tests/hlines.c b/tests/hlines.c new file mode 100644 index 0000000..3246793 --- /dev/null +++ b/tests/hlines.c @@ -0,0 +1,35 @@ +#include "test.h" + +void test(){ + vkvg_surface_clear(surf); + struct timeval currentTime; + gettimeofday(¤tTime, NULL); + + srand((unsigned) currentTime.tv_usec); + const float w = 1024.f; + const float h = 800.f; + + VkvgContext ctx = vkvg_create(surf); + //vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); + vkvg_set_line_width(ctx,20); + //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL); + + for (int i=0; i<250; i++) { + randomize_color(ctx); + float x1 = trunc( ((float)w*rand())/RAND_MAX ); + float y1 = trunc( ((float)h*rand())/RAND_MAX ); + float v = trunc( ((float)500*rand())/RAND_MAX ); + + vkvg_move_to (ctx, x1, y1); + vkvg_line_to (ctx, x1 + v, y1); + vkvg_stroke (ctx); + } + vkvg_destroy(ctx); +} + +int main(int argc, char *argv[]) { + + perform_test (test, 1024, 768); + + return 0; +} diff --git a/tests/lines.c b/tests/lines.c new file mode 100644 index 0000000..0e86481 --- /dev/null +++ b/tests/lines.c @@ -0,0 +1,37 @@ +#include "test.h" + +void test(){ + vkvg_surface_clear(surf); + struct timeval currentTime; + gettimeofday(¤tTime, NULL); + + srand((unsigned) currentTime.tv_usec); + const float w = 1024.f; + const float h = 800.f; + + VkvgContext ctx = vkvg_create(surf); + //vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); + vkvg_set_line_width(ctx,2); + //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL); + vkvg_set_source_rgba(ctx,1.0,0.0,0.0,0.1); + + for (int i=0; i<250; i++) { + randomize_color(ctx); + float x1 = trunc( ((float)w*rand())/RAND_MAX ); + float y1 = trunc( ((float)h*rand())/RAND_MAX ); + float x2 = trunc( ((float)w*rand())/RAND_MAX ) + 1; + float y2 = trunc( ((float)h*rand())/RAND_MAX ) + 1; + + vkvg_move_to (ctx, x1, y1); + vkvg_line_to (ctx, x2, y2); + vkvg_stroke (ctx); + } + vkvg_destroy(ctx); +} + +int main(int argc, char *argv[]) { + + perform_test (test, 1024, 768); + + return 0; +} diff --git a/tests/multilines.c b/tests/multilines.c new file mode 100644 index 0000000..0e86481 --- /dev/null +++ b/tests/multilines.c @@ -0,0 +1,37 @@ +#include "test.h" + +void test(){ + vkvg_surface_clear(surf); + struct timeval currentTime; + gettimeofday(¤tTime, NULL); + + srand((unsigned) currentTime.tv_usec); + const float w = 1024.f; + const float h = 800.f; + + VkvgContext ctx = vkvg_create(surf); + //vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); + vkvg_set_line_width(ctx,2); + //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL); + vkvg_set_source_rgba(ctx,1.0,0.0,0.0,0.1); + + for (int i=0; i<250; i++) { + randomize_color(ctx); + float x1 = trunc( ((float)w*rand())/RAND_MAX ); + float y1 = trunc( ((float)h*rand())/RAND_MAX ); + float x2 = trunc( ((float)w*rand())/RAND_MAX ) + 1; + float y2 = trunc( ((float)h*rand())/RAND_MAX ) + 1; + + vkvg_move_to (ctx, x1, y1); + vkvg_line_to (ctx, x2, y2); + vkvg_stroke (ctx); + } + vkvg_destroy(ctx); +} + +int main(int argc, char *argv[]) { + + perform_test (test, 1024, 768); + + return 0; +} diff --git a/tests/random_rects.c b/tests/random_rects.c index fc69207..4a3b5ac 100644 --- a/tests/random_rects.c +++ b/tests/random_rects.c @@ -1,7 +1,7 @@ #include "test.h" void test(){ - //vkvg_surface_clear(surf); + vkvg_surface_clear(surf); struct timeval currentTime; gettimeofday(¤tTime, NULL); @@ -9,10 +9,11 @@ void test(){ const float w = 1024.f; VkvgContext ctx = vkvg_create(surf); - vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); vkvg_set_line_width(ctx,2); + //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL); vkvg_set_source_rgba(ctx,1.0,0.0,0.0,0.1); - for (int i=0; i<500; i++) { + for (int i=0; i<250; i++) { randomize_color(ctx); float x = trunc( (0.5*(float)w*rand())/RAND_MAX ); float y = trunc( (0.5*(float)w*rand())/RAND_MAX ); @@ -20,8 +21,9 @@ void test(){ float v = trunc( (0.5*(float)w*rand())/RAND_MAX ) + 1; vkvg_rectangle(ctx, x+1, y+1, z, v); - vkvg_fill_preserve(ctx); - randomize_color(ctx); + /*vkvg_fill_preserve(ctx); + randomize_color(ctx);*/ + vkvg_fill(ctx); vkvg_stroke(ctx); } vkvg_destroy(ctx); diff --git a/tests/rect_fill.c b/tests/rect_fill.c index 0e9d0c1..9fe71f7 100644 --- a/tests/rect_fill.c +++ b/tests/rect_fill.c @@ -1,15 +1,26 @@ #include "test.h" void test(){ + vkvg_matrix_t mat; + vkvg_matrix_init_identity(&mat); + vkvg_matrix_scale(&mat,zoom,zoom); + vkvg_matrix_translate(&mat, panX, panY); + vkvg_surface_clear(surf); + VkvgContext ctx = vkvg_create(surf); + vkvg_set_source_rgba(ctx,1.0f,1.0f,1.0f,1); + vkvg_paint(ctx); + + vkvg_set_matrix(ctx,&mat); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); vkvg_set_line_width(ctx,10); - vkvg_set_source_rgba(ctx,0,0,1,0.5); + vkvg_set_source_rgba(ctx,0,0,1,1); vkvg_rectangle(ctx,100,100,200,200); - vkvg_fill(ctx); + /*vkvg_fill(ctx); vkvg_rectangle(ctx,200,200,200,200); - vkvg_set_source_rgba(ctx,1,0,0,0.5); + vkvg_set_source_rgba(ctx,1,0,0,0.5);*/ vkvg_fill(ctx); vkvg_destroy(ctx); diff --git a/tests/svg.c b/tests/svg.c index 3fb5c23..adda167 100644 --- a/tests/svg.c +++ b/tests/svg.c @@ -13,9 +13,9 @@ }*/ static float rotation = 0.f; -static const char* path = "data/tiger.svg"; +//static const char* path = "data/tiger.svg"; //static const char* path = "data/vkvg.svg"; -//static const char* path = "data/testPiece.svg"; +static const char* path = "data/testPiece.svg"; void test_svg_surface() { VkvgSurface svgSurf = vkvg_surface_create_from_svg(device, path); @@ -40,7 +40,7 @@ void test_nsvg() { vkvg_paint(ctx); vkvg_scale(ctx,1.0f,1.0f); - //vkvg_render_svg(ctx, svg, "br0"); + //vkvg_render_svg(ctx, svg, "wq"); vkvg_render_svg(ctx, svg, NULL); vkvg_destroy(ctx); diff --git a/tests/vlines.c b/tests/vlines.c new file mode 100644 index 0000000..525f3d2 --- /dev/null +++ b/tests/vlines.c @@ -0,0 +1,36 @@ +#include "test.h" + +void test(){ + vkvg_surface_clear(surf); + struct timeval currentTime; + gettimeofday(¤tTime, NULL); + + srand((unsigned) currentTime.tv_usec); + const float w = 1024.f; + const float h = 800.f; + + VkvgContext ctx = vkvg_create(surf); + //vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); + vkvg_set_line_width(ctx,1); + //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL); + //vkvg_set_source_rgba(ctx,1.0,0.0,0.0,0.1); + + for (int i=0; i<250; i++) { + randomize_color(ctx); + float x1 = trunc( ((float)w*rand())/RAND_MAX ); + float y1 = trunc( ((float)h*rand())/RAND_MAX ); + float v = trunc( ((float)500*rand())/RAND_MAX ) + 1; + + vkvg_move_to (ctx, x1, y1); + vkvg_line_to (ctx, x1, y1 + v); + vkvg_stroke (ctx); + } + vkvg_destroy(ctx); +} + +int main(int argc, char *argv[]) { + + perform_test (test, 1024, 768); + + return 0; +}