diff mbox

Added Benchmarking Hooks in djpeg Application.

Message ID BANLkTi=Fhv7jVLd0BEgUYi7dwAEP6G5D8Q@mail.gmail.com
State New
Headers show

Commit Message

Mandeep Kumar June 2, 2011, 1:33 p.m. UTC
From 1bd38dda5ac8a392ef067b9812e77f56817bafd1 Mon Sep 17 00:00:00 2001
From: Mandeep Kumar <mandeep.kumar@linaro.org>
Date: Tue, 10 May 2011 15:17:42 -0500
Subject: [PATCH] Added Benchmarking Hooks in djpeg Application.

---
 configure    |    2 +-
 configure.ac |    2 +-
 djpeg.c      |   26 ++++++++++++++++++++++++++
 3 files changed, 28 insertions(+), 2 deletions(-)
 mode change 100644 => 100755 configure.ac

+#endif

 /*
  * This list defines the known output image formats
@@ -588,6 +608,9 @@ main (int argc, char **argv)
   /* Write output file header */
   (*dest_mgr->start_output) (&cinfo, dest_mgr);

+  TIMER_DEFINE_VARS;
+  TIMER_START;
+
   /* Process data */
   while (cinfo.output_scanline < cinfo.output_height) {
     num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
@@ -595,6 +618,9 @@ main (int argc, char **argv)
     (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
   }

+  TIMER_STOP;
+  TIMER_PRINT ("Decoding took %d ms\n", TIMER_GETDIFF_MS());
+
 #ifdef PROGRESS_REPORT
   /* Hack: count final pass as done in case finish_output does an extra pass.
    * The library won't have updated completed_passes.
diff mbox

Patch

diff --git a/configure b/configure
index 70819d2..0dda8b4 100755
--- a/configure
+++ b/configure
@@ -11852,7 +11852,7 @@  if test "x$VERSION_SCRIPT_FLAG" = "x"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
-LDFLAGS="$SAVED_LDFLAGS"
+LDFLAGS="$SAVED_LDFLAGS -lrt"

 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use
version script when building libjpeg-turbo" >&5
 $as_echo_n "checking whether to use version script when building
libjpeg-turbo... " >&6; }
diff --git a/configure.ac b/configure.ac
old mode 100644
new mode 100755
index 3a26104..ec2b7c8
--- a/configure.ac
+++ b/configure.ac
@@ -172,7 +172,7 @@  if test "x$VERSION_SCRIPT_FLAG" = "x"; then
   VERSION_SCRIPT=no
   AC_MSG_RESULT(no)
 fi
-LDFLAGS="$SAVED_LDFLAGS"
+LDFLAGS="$SAVED_LDFLAGS -lrt"

 AC_MSG_CHECKING([whether to use version script when building libjpeg-turbo])
 AC_MSG_RESULT($VERSION_SCRIPT)
diff --git a/djpeg.c b/djpeg.c
index b24694b..da58782 100755
--- a/djpeg.c
+++ b/djpeg.c
@@ -50,6 +50,26 @@  static const char * const cdjpeg_message_table[] = {
   NULL
 };

+#define PROFILE_DECODING
+
+#ifdef PROFILE_DECODING
+#include <time.h>
+
+#define  TIMER_DEFINE_VARS  struct timespec starttime, endtime;
+#define  TIMER_GETDIFF_MS() (long)( (endtime.tv_sec -
starttime.tv_sec)*1000 + (endtime.tv_nsec -
starttime.tv_nsec)/1000000)
+#define  TIMER_START do { clock_gettime (CLOCK_PROCESS_CPUTIME_ID,
&starttime); } while (0)
+#define  TIMER_STOP do { clock_gettime (CLOCK_PROCESS_CPUTIME_ID,
&endtime); } while (0)
+#define  TIMER_PRINT(...) fprintf(stderr, __VA_ARGS__)
+
+#else
+
+#define TIMER_DEFINE_VARS do {} while (0)
+#define TIMER_GETDIFF_MS do {} while (0)
+#define TIMER_START do {} while (0)
+#define TIMER_STOP do {} while (0)
+#define TIMER_PRINT(...) do {} while (0)
+