2 #include <dcp/openjpeg_image.h>
3 #include <boost/thread.hpp>
4 #include <boost/foreach.hpp>
10 using boost::shared_ptr;
13 thread (int iterations)
15 int const width = 1998;
16 int const height = 1080;
18 for (int i = 0; i < iterations; ++i) {
19 shared_ptr<const dcp::OpenJPEGImage> xyz (new dcp::OpenJPEGImage (dcp::Size (width, height)));
20 int32_t* X = xyz->data(0);
21 int32_t* Y = xyz->data(1);
22 int32_t* Z = xyz->data(2);
23 for (int y = 0; y < height; ++y) {
24 for (int x = 0; x < width; ++x) {
27 *Z++ = (x * y) % 4096;
31 dcp::compress_j2k (xyz, 100000000, 24, false, false);
36 main (int argc, char* argv[])
39 cout << "Syntax: " << argv[0] << " <threads> <iterations>\n";
43 int const num_threads = atoi (argv[1]);
44 int const num_iterations = atoi (argv[2]);
45 cout << num_threads << " threads, " << num_iterations << " iterations.\n";
48 gettimeofday (&start, 0);
50 list<boost::thread*> threads;
51 for (int i = 0; i < num_threads; ++i) {
52 threads.push_back (new boost::thread (boost::bind (&thread, num_iterations)));
55 BOOST_FOREACH (boost::thread* i, threads) {
60 gettimeofday (&stop, 0);
62 cout << ((stop.tv_sec + double(stop.tv_usec) / 1000000) - (start.tv_sec + double(start.tv_usec) / 1000000)) << "s\n";