From 02fde2ace97ceff512758442b115b99e1b0f3f80 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 10 Feb 2016 20:22:37 +0000 Subject: [PATCH 1/1] Initial. --- jpwtf.cc | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ make.sh | 3 +++ 2 files changed, 61 insertions(+) create mode 100644 jpwtf.cc create mode 100644 make.sh diff --git a/jpwtf.cc b/jpwtf.cc new file mode 100644 index 0000000..b39017d --- /dev/null +++ b/jpwtf.cc @@ -0,0 +1,58 @@ +#include +#include +#include +#include +#include +#include +#include + +using std::list; +using std::cout; +using boost::shared_ptr; + +void +thread (int iterations) +{ + int const width = 1998; + int const height = 1080; + for (int i = 0; i < iterations; ++i) { + shared_ptr xyz (new dcp::OpenJPEGImage (dcp::Size (width, height))); + int32_t* X = xyz->data(0); + int32_t* Y = xyz->data(1); + int32_t* Z = xyz->data(2); + for (int y = 0; y < height; ++y) { + for (int x = 0; x < width; ++x) { + *X++ = x; + *Y++ = y; + *Z++ = (x * y) % 4096; + } + } + + dcp::compress_j2k (xyz, 100000000, 24, false, false); + } +} + +int +main (int argc, char* argv[]) +{ + int const num_threads = atoi (argv[1]); + int const num_iterations = atoi (argv[2]); + cout << num_threads << " threads, " << num_iterations << " iterations.\n"; + + struct timeval start; + gettimeofday (&start, 0); + + list threads; + for (int i = 0; i < num_threads; ++i) { + threads.push_back (new boost::thread (boost::bind (&thread, num_iterations))); + } + + BOOST_FOREACH (boost::thread* i, threads) { + i->join (); + } + + struct timeval stop; + gettimeofday (&stop, 0); + + cout << ((stop.tv_sec + double(start.tv_usec) / 1000000) - (start.tv_sec + double(stop.tv_usec) / 1000000)) << "s\n"; +} diff --git a/make.sh b/make.sh new file mode 100644 index 0000000..c0d48f1 --- /dev/null +++ b/make.sh @@ -0,0 +1,3 @@ +deps=`pkg-config --cflags --libs libdcp-1.0 | sed -e "s/\\\\\\\\//g"` +echo $deps +g++ -g -o jpwtf jpwtf.cc -O2 $deps -lboost_thread -- 2.30.2