This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via c86751325f6076b6ea840a1a689b99e30f6c35ca (commit) via 8bb3bbff3bf468349be5b2fdd18a3faf4e17a5cb (commit) via 39db9b12008710da657d2fe0aaf3486a2a497a8f (commit) from f6e4b62561d2fa6b7bcc94a24ba3fdaa1763aafe (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/c86751325f6076b6ea840a1a689b99e30f6c3...
commit c86751325f6076b6ea840a1a689b99e30f6c35ca Author: Cyril Hrubis metan@ucw.cz Date: Sat Oct 13 15:26:19 2012 +0200
tests: Sketch gfx benchmarks.
diff --git a/tests/Makefile b/tests/Makefile index f965da6..f4fc735 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,8 +1,9 @@ TOPDIR=.. include $(TOPDIR)/pre.mk
-SUBDIRS=core SDL drivers framework loaders +SUBDIRS=core SDL drivers framework loaders gfx
loaders: framework +gfx: framework
include $(TOPDIR)/post.mk diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile new file mode 100644 index 0000000..ec97b78 --- /dev/null +++ b/tests/gfx/Makefile @@ -0,0 +1,18 @@ +TOPDIR=../.. +include $(TOPDIR)/pre.mk + +CSOURCES=$(shell echo *.c) + +LDFLAGS+=-L../framework/ -L$(TOPDIR)/build/ +LDLIBS+=$(shell $(TOPDIR)/gfxprim-config --libs --libs-loaders) +LDLIBS+=-ltst_preload -ldl -ltst +CFLAGS+=-I../framework/ + +APPS=gfx_benchmark + +$(APPS): ../framework/libtst.a + +CLEAN+=log.html log.json + +include $(TOPDIR)/app.mk +include $(TOPDIR)/post.mk diff --git a/tests/gfx/gfx_benchmark.c b/tests/gfx/gfx_benchmark.c new file mode 100644 index 0000000..0ec61c6 --- /dev/null +++ b/tests/gfx/gfx_benchmark.c @@ -0,0 +1,142 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include <core/GP_Context.h> +#include <gfx/GP_Gfx.h> + +#include "tst_test.h" + +static int bench_line(GP_PixelType type) +{ + GP_Context *img = GP_ContextAlloc(800, 600, type); + + if (img == NULL) { + tst_report(0, "Malloc failed"); + return TST_INTERR; + } + + unsigned int i; + + for (i = 0; i < 100000; i++) { + GP_Line(img, 0 + i % 100, 0 - i % 100, + 800 - i%200, 600 + i%200, i % 0xff); + } + + return TST_SUCCESS; +} + +static int bench_line_1bpp(void) +{ + return bench_line(GP_PIXEL_G1); +} + +static int bench_line_2bpp(void) +{ + return bench_line(GP_PIXEL_G2); +} + +static int bench_line_4bpp(void) +{ + return bench_line(GP_PIXEL_G4); +} + +static int bench_line_8bpp(void) +{ + return bench_line(GP_PIXEL_G8); +} + +static int bench_line_32bpp(void) +{ + return bench_line(GP_PIXEL_RGB888); +} + +static int bench_circle(GP_PixelType type) +{ + GP_Context *img = GP_ContextAlloc(800, 600, type); + + if (img == NULL) { + tst_report(0, "Malloc failed"); + return TST_INTERR; + } + + unsigned int i; + + for (i = 0; i < 100000; i++) { + GP_Circle(img, img->w/2, img->h/2, i % 1000, i%0xff); + } + + return TST_SUCCESS; +} + +static int bench_circle_1bpp(void) +{ + return bench_circle(GP_PIXEL_G1); +} + +static int bench_circle_2bpp(void) +{ + return bench_circle(GP_PIXEL_G2); +} + +static int bench_circle_4bpp(void) +{ + return bench_circle(GP_PIXEL_G4); +} + +static int bench_circle_8bpp(void) +{ + return bench_circle(GP_PIXEL_G8); +} + +static int bench_circle_32bpp(void) +{ + return bench_circle(GP_PIXEL_RGB888); +} + +const struct tst_suite tst_suite = { + .suite_name = "GFX Benchmark", + .tests = { + {.name = "Line 1BPP", .tst_fn = bench_line_1bpp, + .bench_iter = 10}, + {.name = "Line 2BPP", .tst_fn = bench_line_2bpp, + .bench_iter = 10}, + {.name = "Line 4BPP", .tst_fn = bench_line_4bpp, + .bench_iter = 10}, + {.name = "Line 8BPP", .tst_fn = bench_line_8bpp, + .bench_iter = 10}, + {.name = "Line 32BPP", .tst_fn = bench_line_32bpp, + .bench_iter = 10}, + + {.name = "Circle 1BPP", .tst_fn = bench_circle_1bpp, + .bench_iter = 10}, + {.name = "Circle 2BPP", .tst_fn = bench_circle_2bpp, + .bench_iter = 10}, + {.name = "Circle 4BPP", .tst_fn = bench_circle_4bpp, + .bench_iter = 10}, + {.name = "Circle 8BPP", .tst_fn = bench_circle_8bpp, + .bench_iter = 10}, + {.name = "Circle 32BPP", .tst_fn = bench_circle_32bpp, + .bench_iter = 10}, + + {.name = NULL}, + } +}; diff --git a/tests/gfx/runtest.sh b/tests/gfx/runtest.sh new file mode 100755 index 0000000..71a411b --- /dev/null +++ b/tests/gfx/runtest.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# +# By default the glibc __libc_message() writes to /dev/tty before calling +# the abort(). Exporting this macro makes it to use stderr instead. +# +# The main usage of the function are malloc assertions, so this makes us catch +# the malloc error message by catching stderr output. +# +export LIBC_FATAL_STDERR_=1 + +LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./gfx_benchmark "$@"
http://repo.or.cz/w/gfxprim.git/commit/8bb3bbff3bf468349be5b2fdd18a3faf4e17a...
commit 8bb3bbff3bf468349be5b2fdd18a3faf4e17a5cb Author: Cyril Hrubis metan@ucw.cz Date: Sat Oct 13 15:21:58 2012 +0200
tests: framework: Fix test job log output.
Aling better the output on runtime >= 10 sec.
diff --git a/tests/framework/test.c b/tests/framework/test.c index 69a9978..f4a8692 100644 --- a/tests/framework/test.c +++ b/tests/framework/test.c @@ -238,7 +238,7 @@ const struct tst_suite tst_suite = { {.name = "Failed FILE", .tst_fn = fail_FILE, .flags = TST_TMPDIR}, {.name = "Resource", .tst_fn = res_fn, .flags = TST_TMPDIR, .res_path = "test.c"}, - {.name = "Floating point exception", .tst_fn = fpe_fn}, + {.name = "FP exception", .tst_fn = fpe_fn}, {.name = "Benchmark test", .tst_fn = benchmark_fn, .bench_iter = 10}, {.name = NULL}, } diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c index a075c5f..c02fa9f 100644 --- a/tests/framework/tst_job.c +++ b/tests/framework/tst_job.c @@ -60,7 +60,7 @@ void tst_diff_timespec(int *sec, int *nsec, struct timespec *start, } }
-#define NAME_PADD 24 +#define NAME_PADD 23
static void stop_test(struct tst_job *job) { @@ -109,7 +109,7 @@ static void stop_test(struct tst_job *job) for (i = strlen(name); i < NAME_PADD; i++) fprintf(stderr, " ");
- fprintf(stderr, " finished (Time %i.%03is, CPU %i.%03is) %sn", + fprintf(stderr, " finished (Time %2i.%03is, CPU %2i.%03is) %sn", sec, nsec/1000000, (int)job->cpu_time.tv_sec, (int)job->cpu_time.tv_nsec/1000000, @@ -119,7 +119,7 @@ static void stop_test(struct tst_job *job) for (i = 0; i < NAME_PADD; i++) fprintf(stderr, " ");
- fprintf(stderr, " bench CPU %i.%06is +/- %i.%06isn", + fprintf(stderr, " bench CPU time %i.%06is +/- %i.%06isn", (int)job->bench_mean.tv_sec, (int)job->bench_mean.tv_nsec/1000, (int)job->bench_var.tv_sec,
http://repo.or.cz/w/gfxprim.git/commit/39db9b12008710da657d2fe0aaf3486a2a497...
commit 39db9b12008710da657d2fe0aaf3486a2a497a8f Author: Cyril Hrubis metan@ucw.cz Date: Sat Oct 13 15:01:33 2012 +0200
tests: framework: Add benchmark logic.
Now test could be marked as benchmark. Such functions is executed several times and mean and standard deviation are computed.
diff --git a/tests/framework/Makefile b/tests/framework/Makefile index 709f907..7169bb7 100644 --- a/tests/framework/Makefile +++ b/tests/framework/Makefile @@ -17,7 +17,7 @@ ALL+=libtst_preload.so libtst.a libtst_preload.so: tst_preload.o tst_alloc_barriers.o tst_preload_FILE.o gcc -Wl,-soname -Wl,tst_preload.so --shared -ldl -fPIC $^ -o $@
-libtst.a: tst_test.o tst_job.o tst_msg.o tst_log.o tst_main.o +libtst.a: tst_test.o tst_job.o tst_msg.o tst_log.o tst_main.o tst_timespec.o ar rcs $@ $^
CLEAN+=libtst_preload.so libtst.a log.html log.json diff --git a/tests/framework/test.c b/tests/framework/test.c index 48fa872..69a9978 100644 --- a/tests/framework/test.c +++ b/tests/framework/test.c @@ -207,6 +207,20 @@ static int fpe_fn(void) return 1/i; }
+/* + * Let's benchmark memset. + */ +static int benchmark_fn(void) +{ + char buf[256]; + unsigned int i; + + for (i = 0; i < 4000000; i++) + memset(buf, i%100, sizeof(buf)); + + return TST_SUCCESS; +} + const struct tst_suite tst_suite = { .suite_name = "Testing Framework Example", .tests = { @@ -225,6 +239,7 @@ const struct tst_suite tst_suite = { {.name = "Resource", .tst_fn = res_fn, .flags = TST_TMPDIR, .res_path = "test.c"}, {.name = "Floating point exception", .tst_fn = fpe_fn}, + {.name = "Benchmark test", .tst_fn = benchmark_fn, .bench_iter = 10}, {.name = NULL}, } }; diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c index b27b358..a075c5f 100644 --- a/tests/framework/tst_job.c +++ b/tests/framework/tst_job.c @@ -30,10 +30,12 @@ #include <sys/types.h> #include <sys/wait.h> #include <stdarg.h> +#include <math.h>
#include "tst_preload.h" #include "tst_test.h" #include "tst_job.h" +#include "tst_timespec.h"
/* * Once we child forks to do a job, this points to its job structure. @@ -112,6 +114,17 @@ static void stop_test(struct tst_job *job) (int)job->cpu_time.tv_sec, (int)job->cpu_time.tv_nsec/1000000, result); + + if (job->bench_iter) { + for (i = 0; i < NAME_PADD; i++) + fprintf(stderr, " "); + + fprintf(stderr, " bench CPU %i.%06is +/- %i.%06isn", + (int)job->bench_mean.tv_sec, + (int)job->bench_mean.tv_nsec/1000, + (int)job->bench_var.tv_sec, + (int)job->bench_var.tv_nsec/1000); + }
if (job->result == TST_MEMLEAK) tst_malloc_print(&job->malloc_stats); @@ -265,6 +278,69 @@ int tst_report(int level, const char *fmt, ...) return ret; }
+/* + * Run benchmark job and compute result + */ +static int tst_job_benchmark(struct tst_job *job) +{ + unsigned int i, iter = job->test->bench_iter; + struct timespec cputime_start; + struct timespec cputime_stop; + struct timespec bench[iter]; + struct timespec sum = {.tv_sec = 0, .tv_nsec = 0}; + struct timespec dev = {.tv_sec = 0, .tv_nsec = 0}; + int ret; + + /* Warm up */ + ret = job->test->tst_fn(); + + if (ret) + return ret; + + /* Collect the data */ + for (i = 0; i < iter; i++) { + clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &cputime_start); + + ret = job->test->tst_fn(); + + if (ret) + return ret; + + clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &cputime_stop); + + timespec_sub(&cputime_stop, &cputime_start, &bench[i]); + + timespec_add(&bench[i], &sum); + } + + /* Compute mean */ + timespec_div(&sum, iter); + + double sum_d = timespec_to_double(&sum); + double dev_d = 0; + + /* And standard deviation */ + for (i = 0; i < iter; i++) { + double b = timespec_to_double(&bench[i]); + + b -= sum_d; + b = b * b; + + dev_d += b; + } + + dev_d /= iter; + dev_d = sqrt(dev_d); + + double_to_timespec(dev_d, &dev); + + /* Send data to parent */ + write_timespec(job, 'M', &sum); + write_timespec(job, 'D', &dev); + + return TST_SUCCESS; +} + void tst_job_run(struct tst_job *job) { int ret; @@ -280,6 +356,9 @@ void tst_job_run(struct tst_job *job) /* marks test as started */ start_test(job);
+ /* copy benchmark interation */ + job->bench_iter = job->test->bench_iter; + if (pipe(pipefd)) { tst_warn("pipefd() failed: %s", strerror(errno)); job->running = 0; @@ -335,7 +414,10 @@ void tst_job_run(struct tst_job *job) tst_malloc_check_start();
/* Run test */ - ret = job->test->tst_fn(); + if (job->test->bench_iter) + ret = tst_job_benchmark(job); + else + ret = job->test->tst_fn();
if (job->test->flags & TST_CHECK_MALLOC) { tst_malloc_check_stop(); @@ -426,6 +508,13 @@ void tst_job_wait(struct tst_job *job) case 'C': read_timespec(job, &job->cpu_time); break; + /* benchmark data */ + case 'M': + read_timespec(job, &job->bench_mean); + break; + case 'V': + read_timespec(job, &job->bench_var); + break; /* test message as generated by tst_report() */ case 'm': parent_read_msg(job); diff --git a/tests/framework/tst_job.h b/tests/framework/tst_job.h index 2e74a7d..76984e5 100644 --- a/tests/framework/tst_job.h +++ b/tests/framework/tst_job.h @@ -64,6 +64,11 @@ struct tst_job { /* test result */ enum tst_ret result;
+ /* additional benchmark data */ + unsigned int bench_iter; + struct timespec bench_mean; + struct timespec bench_var; + /* * test malloc statistics, filled if TST_MALLOC_CHECK was set. */ diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c index 2991c0a..b1e43b8 100644 --- a/tests/framework/tst_log.c +++ b/tests/framework/tst_log.c @@ -186,6 +186,58 @@ static void malloc_stats_html(struct tst_job *job, FILE *f, const char *padd) fprintf(f, "%s</tr>n", padd); }
+static void benchmark_stats_html(struct tst_job *job, FILE *f, const char *padd) +{ + /* Create innter table */ + fprintf(f, "%s<tr>n", padd); + fprintf(f, "%s <td bgcolor="#fd8" colspan="3">n", padd); + fprintf(f, "%s <center>n", padd); + fprintf(f, "%s <table>n", padd); + + /* Create header */ + fprintf(f, "%s <tr>n", padd); + + fprintf(f, "%s <td colspan="2" bgcolor="#fb2">n", padd); + fprintf(f, "%s <center><small>Benchmark data", padd); + fprintf(f, "</small></center>n"); + fprintf(f, "%s </td>n", padd); + + fprintf(f, "%s </tr>n", padd); + fprintf(f, "%s <tr>n", padd); + + fprintf(f, "%s <td bgcolor="#fc4">n", padd); + fprintf(f, "%s <center><small>Iterations", padd); + fprintf(f, "</small></center>n"); + fprintf(f, "%s </td>n", padd); + + fprintf(f, "%s <td bgcolor="#fc4">n", padd); + fprintf(f, "%s <center><small>Mean ∓ Variance", padd); + fprintf(f, "</small></center>n"); + fprintf(f, "%s </td>n", padd); + + fprintf(f, "%s </tr>n", padd); + + /* Create data */ + fprintf(f, "%s <tr>n", padd); + + fprintf(f, "%s <td bgcolor="#fc4">n", padd); + fprintf(f, "%s <center>%i</center>n", padd, job->bench_iter); + fprintf(f, "%s </td>n", padd); + + fprintf(f, "%s <td bgcolor="#fc4">n", padd); + fprintf(f, "%s <center>%i.%06is ∓ %i.%06is</center>n", padd, + (int)job->bench_mean.tv_sec, (int)job->bench_mean.tv_nsec/1000, + (int)job->bench_var.tv_sec, (int)job->bench_var.tv_nsec/1000); + fprintf(f, "%s </td>n", padd); + + fprintf(f, "%s </tr>n", padd); + + fprintf(f, "%s </table>n", padd); + fprintf(f, "%s </center>n", padd); + fprintf(f, "%s </td>n", padd); + fprintf(f, "%s</tr>n", padd); +} + static int append_html(struct tst_job *job, FILE *f) { const char *padd = " "; @@ -201,12 +253,15 @@ static int append_html(struct tst_job *job, FILE *f) bgcol = "#ddddee";
fprintf(f, "%s<tr>n", padd); - fprintf(f, "%s <td bgcolor="%s">%s </td>n", padd, bgcol, job->test->name); + fprintf(f, "%s <td bgcolor="%s">%s </td>n", + padd, bgcol, job->test->name); fprintf(f, "%s <td bgcolor="%s">n", padd, bgcol); - fprintf(f, "%s <center><small><font color="#222">%i.%03is %i.%03is</font></small></center>", - padd, sec, nsec/1000000, (int)job->cpu_time.tv_sec, (int)job->cpu_time.tv_nsec/1000000); + fprintf(f, "%s <center><small><font color="#222">%i.%03is %i.%03is" + "</font></small></center>n", padd, sec, nsec/1000000, + (int)job->cpu_time.tv_sec, (int)job->cpu_time.tv_nsec/1000000); fprintf(f, "%s </td>n", padd); - fprintf(f, "%s <td bgcolor="%s"><center><font color="white"> %s </td></center>n", padd, + fprintf(f, "%s <td bgcolor="%s"><center><font color="white">" + " %s </td></center>n", padd, ret_to_bg_color(job->result), ret_to_str(job->result));
struct tst_msg *msg; @@ -215,10 +270,14 @@ static int append_html(struct tst_job *job, FILE *f) if (job->test->flags & TST_CHECK_MALLOC) malloc_stats_html(job, f, padd);
+ if (job->bench_iter) + benchmark_stats_html(job, f, padd); + for (msg = job->store.first; msg != NULL; msg = msg->next) { fprintf(f, "%s<tr>n", padd); fprintf(f, "%s <td colspan="3" bgcolor="#eeeeee">n", padd); - fprintf(f, "%s <small>%s</small>n", padd, msg->msg); + fprintf(f, "%s <small>%s</small>n", + padd, msg->msg); fprintf(f, "%s </td>n", padd); fprintf(f, "%s</tr>n", padd); } @@ -268,6 +327,23 @@ static int append_malloc_stats_json(struct tst_job *job, FILE *f) return 0; }
+static void append_benchmark_json(struct tst_job *job, FILE *f) +{ + fprintf(f, "ttt"Benchmark": {n"); + + fprintf(f, "tttt"Time Mean": %i.%09i,n", + (int)job->bench_mean.tv_sec, + (int)job->bench_mean.tv_nsec); + + fprintf(f, "tttt"Time Variance": %i.%09i,n", + (int)job->bench_var.tv_sec, + (int)job->bench_var.tv_nsec); + + fprintf(f, "tttt"Iterations": %in", job->bench_iter); + + fprintf(f, "ttt}n"); +} + static int hack_json_start = 0;
static int append_json(struct tst_job *job, FILE *f) @@ -287,7 +363,11 @@ static int append_json(struct tst_job *job, FILE *f) /* If calculated include malloc report */ if (job->test->flags & TST_CHECK_MALLOC) append_malloc_stats_json(job, f); - + + /* If benchmark data were created */ + if (job->bench_iter) + append_benchmark_json(job, f); + /* Time statistics */ int sec, nsec;
@@ -328,7 +408,8 @@ FILE *open_html(const struct tst_suite *suite, const char *path) if (f == NULL) return NULL;
- fprintf(f, "<html>n <head>n </head>n <body>n <table bgcolor="#99a">n"); + fprintf(f, "<html>n <head>n </head>n <body>n " + "<table bgcolor="#99a">n");
fprintf(f, " <tr><td colspan="3" bgcolor="#bbbbff"><center><b>%s" "</b></center></td></tr>n", suite->suite_name); diff --git a/tests/framework/tst_test.h b/tests/framework/tst_test.h index 195b040..b9a0c17 100644 --- a/tests/framework/tst_test.h +++ b/tests/framework/tst_test.h @@ -57,6 +57,13 @@ struct tst_test { * test directory before test is executed. */ const char *res_path; + /* + * If not zero, the test is benchmark. + * + * The test_fn is executed bench_iter times and bench + * data are filled. + */ + unsigned int bench_iter; /* test function */ int (*tst_fn)(void); /* time limit in seconds 0 == unlimited */ diff --git a/tests/framework/tst_job.h b/tests/framework/tst_timespec.c similarity index 58% copy from tests/framework/tst_job.h copy to tests/framework/tst_timespec.c index 2e74a7d..d388502 100644 --- a/tests/framework/tst_job.h +++ b/tests/framework/tst_timespec.c @@ -20,72 +20,58 @@ * * *****************************************************************************/
- /* - - Test job is an instance of running test. +#include "tst_timespec.h"
- */ +#define NSEC_IN_SEC 1000000000
-#ifndef TST_JOB_H -#define TST_JOB_H +double timespec_to_double(const struct timespec *t) +{ + double res; + + res = t->tv_sec; + res *= NSEC_IN_SEC; + res += t->tv_nsec;
-#include <time.h> + return res; +}
-#include "tst_msg.h" -#include "tst_preload.h" -#include "tst_test.h" +void double_to_timespec(const double time, struct timespec *res) +{ + res->tv_sec = time / NSEC_IN_SEC; + res->tv_nsec = time - res->tv_sec * NSEC_IN_SEC; +}
-struct tst_job { - const struct tst_test *test; - - /* - * Pipe fd. - * - * In parent this points to the read side of the pipe so the parent - * recieves data from child. - * - * In child this points to the write side of the pipe so child can - * send data to parent. - */ - int pipefd; - - int running:1; - - /* test execution time */ - struct timespec start_time; - struct timespec stop_time; - - /* test cpu time */ - struct timespec cpu_time; +void timespec_sub(const struct timespec *a, const struct timespec *b, + struct timespec *res) +{ + res->tv_sec = a->tv_sec - b->tv_sec; + time_t nsec = a->tv_nsec;
- /* test pid */ - int pid; - - /* test result */ - enum tst_ret result; + if (b->tv_nsec > a->tv_nsec) { + res->tv_sec--; + nsec += NSEC_IN_SEC; + }
- /* - * test malloc statistics, filled if TST_MALLOC_CHECK was set. - */ - struct malloc_stats malloc_stats; + res->tv_nsec = nsec - b->tv_nsec; +}
- /* store for test messages */ - struct tst_msg_store store; -}; +void timespec_add(const struct timespec *a, struct timespec *res) +{ + res->tv_sec += a->tv_sec; + res->tv_nsec += a->tv_nsec;
-/* - * Runs a test job as a separate process. - * - * The test field must point to correct test. - */ -void tst_job_run(struct tst_job *job); + if (res->tv_nsec >= NSEC_IN_SEC) { + res->tv_sec += res->tv_nsec / NSEC_IN_SEC; + res->tv_nsec %= NSEC_IN_SEC; + } +}
-/* - * Waits for the test to finish. - */ -void tst_job_wait(struct tst_job *job); +void timespec_div(struct timespec *res, unsigned int div) +{ + long sec = res->tv_sec;
-void tst_diff_timespec(int *sec, int *nsec, struct timespec *start, - struct timespec *stop); + res->tv_sec /= div; + sec %= div;
-#endif /* TST_JOB_H */ + res->tv_nsec = (sec * NSEC_IN_SEC + res->tv_nsec)/div; +} diff --git a/tests/framework/tst_job.h b/tests/framework/tst_timespec.h similarity index 58% copy from tests/framework/tst_job.h copy to tests/framework/tst_timespec.h index 2e74a7d..25d010c 100644 --- a/tests/framework/tst_job.h +++ b/tests/framework/tst_timespec.h @@ -22,70 +22,24 @@
/*
- Test job is an instance of running test. + Timespec manipulation utils.
*/
-#ifndef TST_JOB_H -#define TST_JOB_H +#ifndef TST_TIMESPEC_H +#define TST_TIMESPEC_H
#include <time.h>
-#include "tst_msg.h" -#include "tst_preload.h" -#include "tst_test.h" +double timespec_to_double(const struct timespec *t);
-struct tst_job { - const struct tst_test *test; - - /* - * Pipe fd. - * - * In parent this points to the read side of the pipe so the parent - * recieves data from child. - * - * In child this points to the write side of the pipe so child can - * send data to parent. - */ - int pipefd; - - int running:1; - - /* test execution time */ - struct timespec start_time; - struct timespec stop_time; - - /* test cpu time */ - struct timespec cpu_time; +void double_to_timespec(const double time, struct timespec *res);
- /* test pid */ - int pid; - - /* test result */ - enum tst_ret result; +void timespec_sub(const struct timespec *a, const struct timespec *b, + struct timespec *res);
- /* - * test malloc statistics, filled if TST_MALLOC_CHECK was set. - */ - struct malloc_stats malloc_stats; +void timespec_add(const struct timespec *a, struct timespec *res);
- /* store for test messages */ - struct tst_msg_store store; -}; +void timespec_div(struct timespec *res, unsigned int div);
-/* - * Runs a test job as a separate process. - * - * The test field must point to correct test. - */ -void tst_job_run(struct tst_job *job); - -/* - * Waits for the test to finish. - */ -void tst_job_wait(struct tst_job *job); - -void tst_diff_timespec(int *sec, int *nsec, struct timespec *start, - struct timespec *stop); - -#endif /* TST_JOB_H */ +#endif /* TST_TIMESPEC_H */
-----------------------------------------------------------------------
Summary of changes: tests/Makefile | 3 +- tests/framework/Makefile | 2 +- tests/framework/test.c | 17 +++- tests/framework/tst_job.c | 95 +++++++++++++- tests/framework/tst_job.h | 5 + tests/framework/tst_log.c | 95 ++++++++++++- tests/framework/tst_test.h | 7 + tests/framework/{tst_msg.c => tst_timespec.c} | 77 +++++------ .../cpu_timer.h => tests/framework/tst_timespec.h | 39 +++--- tests/{loaders => gfx}/Makefile | 4 +- tests/gfx/gfx_benchmark.c | 142 ++++++++++++++++++++ tests/{loaders => gfx}/runtest.sh | 2 +- 12 files changed, 409 insertions(+), 79 deletions(-) copy tests/framework/{tst_msg.c => tst_timespec.c} (61%) copy demos/spiv/cpu_timer.h => tests/framework/tst_timespec.h (78%) copy tests/{loaders => gfx}/Makefile (83%) create mode 100644 tests/gfx/gfx_benchmark.c copy tests/{loaders => gfx}/runtest.sh (91%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.