2 Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 using boost::shared_ptr;
31 /** Run some basic benchmarks of JPEG2000 encoding / decoding */
33 main (int argc, char* argv[])
36 cerr << "Syntax: " << argv[0] << " private-test-path\n";
40 int const decompress_count = 100;
41 int const compress_count = 100;
42 int const j2k_bandwidth = 100000000;
45 dcp::Data j2k (boost::filesystem::path (argv[1]) / "thx.j2c");
47 gettimeofday (&start, 0);
49 shared_ptr<dcp::OpenJPEGImage> xyz;
50 for (int i = 0; i < decompress_count; ++i) {
51 xyz = dcp::decompress_j2k (j2k, 0);
52 cout << (i + 1) << " ";
58 gettimeofday (&stop, 0);
60 double start_seconds = start.tv_sec + double(start.tv_usec) / 1000000;
61 double stop_seconds = stop.tv_sec + double(stop.tv_usec) / 1000000;
62 if (dcp::built_with_debug) {
63 cout << "Decompress (debug build): ";
65 cout << "Decompress: ";
67 cout << decompress_count / (stop_seconds - start_seconds) << " fps.\n";
69 gettimeofday (&start, 0);
71 for (int i = 0; i < compress_count; ++i) {
72 dcp::compress_j2k (xyz, j2k_bandwidth, 24, false, false);
73 cout << (i + 1) << " ";
78 gettimeofday (&stop, 0);
80 start_seconds = start.tv_sec + double(start.tv_usec) / 1000000;
81 stop_seconds = stop.tv_sec + double(stop.tv_usec) / 1000000;
82 if (dcp::built_with_debug) {
83 cout << "Compress (debug build) ";
88 cout << (j2k_bandwidth / 1000000) << "Mbps: "
89 << compress_count / (stop_seconds - start_seconds) << " fps.\n";