Rename to j2kbench.
authorCarl Hetherington <cth@carlh.net>
Tue, 5 Jul 2016 19:13:57 +0000 (20:13 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 5 Jul 2016 19:13:57 +0000 (20:13 +0100)
.gitignore [new file with mode: 0644]
j2kbench.cc [new file with mode: 0644]
jpwtf.cc [deleted file]
make.sh

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..d3cc639
--- /dev/null
@@ -0,0 +1,2 @@
+*~
+j2kbench
diff --git a/j2kbench.cc b/j2kbench.cc
new file mode 100644 (file)
index 0000000..f81e7f6
--- /dev/null
@@ -0,0 +1,63 @@
+#include <dcp/j2k.h>
+#include <dcp/openjpeg_image.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[])
+{
+       if (argc < 3) {
+               cout << "Syntax: " << argv[0] << " <threads> <iterations>\n";
+               exit (EXIT_FAILURE);
+       }
+
+       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(stop.tv_usec) / 1000000) - (start.tv_sec + double(start.tv_usec) / 1000000)) << "s\n";
+}
diff --git a/jpwtf.cc b/jpwtf.cc
deleted file mode 100644 (file)
index b0d0f01..0000000
--- a/jpwtf.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-#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(stop.tv_usec) / 1000000) - (start.tv_sec + double(start.tv_usec) / 1000000)) << "s\n";
-}
diff --git a/make.sh b/make.sh
index c0d48f17f7ce4c7256ee88c6beb4f15499b5cfed..94ba6c843022c2a566718965c11ce10efdd63d7d 100644 (file)
--- a/make.sh
+++ b/make.sh
@@ -1,3 +1,2 @@
 deps=`pkg-config --cflags --libs libdcp-1.0 | sed -e "s/\\\\\\\\//g"`
-echo $deps
-g++ -g -o jpwtf jpwtf.cc -O2 $deps -lboost_thread
+g++ -g -o j2kbench j2kbench.cc -O2 $deps -lboost_thread