summaryrefslogtreecommitdiff
path: root/benchmark/j2k_transcode.cc
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/j2k_transcode.cc')
-rw-r--r--benchmark/j2k_transcode.cc26
1 files changed, 16 insertions, 10 deletions
diff --git a/benchmark/j2k_transcode.cc b/benchmark/j2k_transcode.cc
index 71602e0b..1e628079 100644
--- a/benchmark/j2k_transcode.cc
+++ b/benchmark/j2k_transcode.cc
@@ -37,6 +37,7 @@
#include "openjpeg_image.h"
#include "util.h"
#include "version.h"
+#include <boost/thread/thread.hpp>
#include <sys/time.h>
#include <iostream>
#include <cstdio>
@@ -86,8 +87,9 @@ main (int argc, char* argv[])
exit (EXIT_FAILURE);
}
- int const count = 100;
+ int const count = 128;
int const j2k_bandwidth = 100000000;
+ int const threads = 16;
dcp::ArrayData j2k (boost::filesystem::path (argv[1]) / "thx.j2c");
@@ -95,16 +97,20 @@ main (int argc, char* argv[])
Timer compress;
dcp::ArrayData recomp;
- for (int i = 0; i < count; ++i) {
- decompress.start ();
- shared_ptr<dcp::OpenJPEGImage> xyz = dcp::decompress_j2k (j2k, 0);
- decompress.stop ();
- compress.start ();
- recomp = dcp::compress_j2k (xyz, j2k_bandwidth, 24, false, false);
- compress.stop ();
- cout << (i + 1) << " ";
- cout.flush ();
+
+ auto body = [&]() {
+ for (int i = 0; i < (count / threads); ++i) {
+ auto xyz = dcp::decompress_j2k(j2k, 0);
+ }
+ };
+
+ boost::thread_group group;
+ decompress.start ();
+ for (int i = 0; i < threads; ++i) {
+ group.create_thread(body);
}
+ group.join_all();
+ decompress.stop ();
cout << "\n";
cout << "Decompress: " << count / decompress.get() << " fps.\n";