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 c5d3e2a62fabfd142f86d47f51e313680d363ea3 (commit) from bccb0491d955bfbd1c0cb8d9ca7add8c886c50fe (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/c5d3e2a62fabfd142f86d47f51e313680d363...
commit c5d3e2a62fabfd142f86d47f51e313680d363ea3 Author: Cyril Hrubis metan@ucw.cz Date: Sat Jan 21 21:59:13 2012 +0100
demos: fbshow add more timers.
diff --git a/demos/fbshow/Makefile b/demos/fbshow/Makefile index 6b04464..74d83fb 100644 --- a/demos/fbshow/Makefile +++ b/demos/fbshow/Makefile @@ -9,5 +9,7 @@ LDLIBS+=-lGP -lGP_backends -lSDL -L$(TOPDIR)/build/
APPS=fbshow
+fbshow: cpu_timer.o + include $(TOPDIR)/include.mk include $(TOPDIR)/app.mk diff --git a/demos/fbshow/cpu_timer.c b/demos/fbshow/cpu_timer.c new file mode 100644 index 0000000..88455eb --- /dev/null +++ b/demos/fbshow/cpu_timer.c @@ -0,0 +1,48 @@ +/***************************************************************************** + * 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 <stdio.h> +#include "cpu_timer.h" + +void cpu_timer_start(struct cpu_timer *self, const char *name) +{ + self->name = name; + clock_gettime(CLOCK_THREAD_CPUTIME_ID, &self->t_start); +} + +void cpu_timer_stop(struct cpu_timer *self) +{ + clock_gettime(CLOCK_THREAD_CPUTIME_ID, &self->t_stop); + + int sec; + int nsec; + + if (self->t_stop.tv_nsec < self->t_start.tv_nsec) { + sec = self->t_stop.tv_sec - self->t_start.tv_sec - 1; + nsec = self->t_stop.tv_nsec + 1000000000 - self->t_start.tv_nsec; + } else { + sec = self->t_stop.tv_sec - self->t_start.tv_sec; + nsec = self->t_stop.tv_nsec - self->t_start.tv_nsec; + } + + printf("TIMER '%s' %i.%09i secn", self->name, sec, nsec); +} diff --git a/demos/fbshow/cpu_timer.h b/demos/fbshow/cpu_timer.h new file mode 100644 index 0000000..1b41144 --- /dev/null +++ b/demos/fbshow/cpu_timer.h @@ -0,0 +1,50 @@ +/***************************************************************************** + * 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 * + * * + *****************************************************************************/ + + /* + + Simple timers to count cpu time. + + */ + +#ifndef __CPU_TIMER_H__ +#define __CPU_TIMER_H__ + +#include <time.h> + +struct cpu_timer { + struct timespec t_start; + struct timespec t_stop; + const char *name; +}; + +/* + * Inialize cpu timer. + */ +void cpu_timer_start(struct cpu_timer *self, const char *name); + +/* + * Stops cpu timer and prints result. + */ +void cpu_timer_stop(struct cpu_timer *self); + +#endif /* __CPU_TIMER_H__ */ diff --git a/demos/fbshow/fbshow.c b/demos/fbshow/fbshow.c index f7ab61f..4d9f6bc 100644 --- a/demos/fbshow/fbshow.c +++ b/demos/fbshow/fbshow.c @@ -35,6 +35,8 @@ #include <backends/GP_Backends.h> #include <input/GP_InputDriverLinux.h>
+#include "cpu_timer.h" + static GP_Pixel black_pixel; static GP_Pixel white_pixel;
@@ -106,40 +108,14 @@ static const char *img_name(const char *img_path) return NULL; }
-#include <time.h> - -static struct timespec t_start; -static struct timespec t_stop; -static const char *t_name; - -static void timer_start(const char *name) -{ - t_name = name; - clock_gettime(CLOCK_THREAD_CPUTIME_ID, &t_start); -} - -static void timer_stop(void) -{ - clock_gettime(CLOCK_THREAD_CPUTIME_ID, &t_stop); - - int sec; - int nsec; - - if (t_stop.tv_nsec < t_start.tv_nsec) { - sec = t_stop.tv_sec - t_start.tv_sec - 1; - nsec = t_stop.tv_nsec + 1000000000 - t_start.tv_nsec; - } else { - sec = t_stop.tv_sec - t_start.tv_sec; - nsec = t_stop.tv_nsec - t_start.tv_nsec; - } - - printf("TIMER '%s' %i.%09i secn", t_name, sec, nsec); -} - static void *image_loader(void *ptr) { struct loader_params *params = ptr; GP_ProgressCallback callback = {.callback = image_loader_callback}; + struct cpu_timer timer; + struct cpu_timer sum_timer; + + cpu_timer_start(&sum_timer, "sum");
show_progress = params->show_progress || params->show_progress_once; params->show_progress_once = 0; @@ -149,7 +125,8 @@ static void *image_loader(void *ptr) GP_Context *img = NULL;
callback.priv = "Loading image"; - + + cpu_timer_start(&timer, "Loading"); if (GP_LoadImage(params->img_path, &img, &callback) != 0) { GP_Fill(context, black_pixel); GP_Text(context, NULL, context->w/2, context->h/2, @@ -157,7 +134,8 @@ static void *image_loader(void *ptr) "Failed to load image :("); return NULL; } - + cpu_timer_stop(&timer); + GP_Size w, h;
switch (rotate) { @@ -189,16 +167,18 @@ static void *image_loader(void *ptr) GP_Context *ret;
if (rat < 1) { - timer_start("blur"); + cpu_timer_start(&timer, "Blur"); callback.priv = "Blurring Image"; if (GP_FilterGaussianBlur(img, img, 0.5/rat, 0.5/rat, &callback) == NULL) return NULL; - timer_stop(); + cpu_timer_stop(&timer); }
+ cpu_timer_start(&timer, "Resampling"); callback.priv = "Resampling Image"; ret = GP_FilterResize(img, NULL, GP_INTERP_CUBIC_INT, img->w * rat, img->h * rat, &callback); GP_ContextFree(img); + cpu_timer_stop(&timer);
if (ret == NULL) return NULL; @@ -240,6 +220,8 @@ static void *image_loader(void *ptr) GP_FillRectXYWH(context, ret->w+cx, 0, cx, context->h, black_pixel); GP_FillRectXYWH(context, 0, ret->h+cy, context->w, cy, black_pixel);
+ cpu_timer_stop(&sum_timer); + if (!params->show_info) { GP_BackendFlip(backend); return NULL;
-----------------------------------------------------------------------
Summary of changes: demos/fbshow/Makefile | 2 + .../GP_Backends.h => demos/fbshow/cpu_timer.c | 37 ++++++++------ .../GP_Backends.h => demos/fbshow/cpu_timer.h | 29 +++++++---- demos/fbshow/fbshow.c | 50 ++++++------------- 4 files changed, 57 insertions(+), 61 deletions(-) copy include/backends/GP_Backends.h => demos/fbshow/cpu_timer.c (71%) copy include/backends/GP_Backends.h => demos/fbshow/cpu_timer.h (80%)
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.