--- /dev/null
+#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";
+}