Initial.
authorCarl Hetherington <cth@carlh.net>
Wed, 10 Feb 2016 20:22:37 +0000 (20:22 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 10 Feb 2016 20:22:37 +0000 (20:22 +0000)
jpwtf.cc [new file with mode: 0644]
make.sh [new file with mode: 0644]

diff --git a/jpwtf.cc b/jpwtf.cc
new file mode 100644 (file)
index 0000000..b39017d
--- /dev/null
+++ b/jpwtf.cc
@@ -0,0 +1,58 @@
+#include <dcp/j2k.h>
+#include <dcp/openjpeg_image.h>
+#include <openjpeg.h>
+#include <boost/thread.hpp>
+#include <boost/foreach.hpp>
+#include <list>
+#include <iostream>
+
+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<const dcp::OpenJPEGImage> 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<boost::thread*> 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 (file)
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