Skip to content
Snippets Groups Projects
Commit 5c29e3e8 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

CoreIOTest beautified and performance measured.

parent 608dcb5a
No related branches found
No related tags found
No related merge requests found
......@@ -57,7 +57,7 @@ std::string Benchmark::report() const
for (auto it = m_data.begin(); it!= m_data.end(); ++it) {
std::string name(it->first);
name.resize(20, ' ');
name.resize(30, ' ');
result << name << " : " << std::setprecision(6) << it->second->runTime() << "\n";
}
......
......@@ -21,62 +21,75 @@
#include <cassert>
#include <random>
#include <iomanip>
#include <boost/format.hpp>
bool CoreIOTest::runTest()
{
std::cout << "CoreIOTest::runTest()" << std::endl;
test_configuration(1024, 768, false);
test_configuration(1024, 768, true);
test_configuration(2048, 2048, true);
bool success(true);
return true;
}
// 1024x768, zeros
success &= test_io(1024, 768, false, "int");
success &= test_io(1024, 768, false, "int.gz");
success &= test_io(1024, 768, false, "int.bz2");
void CoreIOTest::test_configuration(int nx, int ny, bool random_data)
{
Benchmark bm;
// 1024x768, random data
success &= test_io(1024, 768, true, "int");
success &= test_io(1024, 768, true, "int.gz");
success &= test_io(1024, 768, true, "int.bz2");
std::ostringstream report;
report << std::string(60, '-') << "\n";
report << "Test " << nx << "x" << ny << (random_data ? " random data" : " zeros") << "\n";
// 2048x2048, random data
success &= test_io(2048, 2048, true, "int");
success &= test_io(2048, 2048, true, "int.gz");
success &= test_io(2048, 2048, true, "int.bz2");
bm.start("createData");
auto ref_data = createData(nx, ny, random_data);
bm.stop("createData");
std::cout << report() << std::endl;
bm.start("write gz");
IntensityDataIOFactory::writeOutputData(*ref_data, "xxx.int.gz");
bm.stop("write gz");
return success;
}
bm.start("write bz2");
IntensityDataIOFactory::writeOutputData(*ref_data, "xxx.int.bz2");
bm.stop("write bz2");
bool CoreIOTest::test_io(int nx, int ny, bool random_data, const std::string& ext)
{
std::cout << "Test " << nx << "x" << ny << ", "
<< (random_data ? "random data" : "zeros")
<< ", file_format: " << ext << "\n";
TestResults result;
result.m_nx = nx;
result.m_ny = ny;
result.m_data_type = random_data;
result.m_file_format = ext;
bm.start("write int");
IntensityDataIOFactory::writeOutputData(*ref_data, "xxx.int");
bm.stop("write int");
Benchmark mb;
bm.start("read gz");
auto data_gz = IntensityDataIOFactory::readOutputData("xxx.int.gz");
bm.stop("read gz");
std::string test_name("create_data");
mb.start(test_name);
auto ref_data = createData(nx, ny, random_data);
mb.stop(test_name);
result.m_create_data_time = mb.runTime(test_name);
bm.start("read bz2");
auto data_bz2 = IntensityDataIOFactory::readOutputData("xxx.int.bz2");
bm.stop("read bz2");
test_name = "write";
mb.start(test_name);
IntensityDataIOFactory::writeOutputData(*ref_data, "xxx."+ext);
mb.stop(test_name);
result.m_write_time = mb.runTime(test_name);
bm.start("read int");
auto data_int = IntensityDataIOFactory::readOutputData("xxx.int");
bm.stop("read int");
test_name = "read";
mb.start(test_name);
auto data = IntensityDataIOFactory::readOutputData("xxx."+ext);
mb.stop(test_name);
result.m_read_time = mb.runTime(test_name);
report << bm.report();
result.m_biggest_diff = biggest_difference(*data, *ref_data);;
report << "Diff_gz: " << biggest_difference(*data_gz, *ref_data)
<< " Diff_bz: " << biggest_difference(*data_bz2, *ref_data)
<< " Diff_int: " << biggest_difference(*data_int, *ref_data)
<< "\n";
std::cout << mb.report() << std::endl;
std::cout << "Diff: " << result.m_biggest_diff << std::endl;
std::cout << report.str() << std::endl;
m_test_results.push_back(result);
bool success = result.m_biggest_diff < 1e-10 ? true : false;
return success;
}
std::unique_ptr<OutputData<double>> CoreIOTest::createData(int nx, int ny, bool fill)
......@@ -98,7 +111,7 @@ std::unique_ptr<OutputData<double>> CoreIOTest::createData(int nx, int ny, bool
return result;
}
//! Returns biggest element difference found;
//! Returns biggest element difference found.
double CoreIOTest::biggest_difference(const OutputData<double>& data, const OutputData<double>& ref)
{
......@@ -113,3 +126,20 @@ double CoreIOTest::biggest_difference(const OutputData<double>& data, const Outp
}
return max_diff;
}
std::string CoreIOTest::report() const
{
std::ostringstream result;
result << "--- CoreIOTest::report() ---\n";
result << "Size | format | data | create read write | diff \n";
for(auto res : m_test_results) {
result << boost::format("%-4dx%-4d | %-10s | %1d | %-7.3f %-7.3f %-7.3f | %g \n")
% res.m_nx % res.m_ny %res.m_file_format
% res.m_data_type
% res.m_create_data_time % res.m_read_time % res.m_write_time
% res.m_biggest_diff;
}
return result.str();
}
......@@ -18,6 +18,7 @@
#include "IFunctionalTest.h"
#include "OutputData.h"
#include "Benchmark.h"
#include <memory>
//! Functional test to validate read/write of large data files.
......@@ -31,10 +32,24 @@ public:
bool runTest();
private:
void test_configuration(int nx, int ny, bool random_data = false);
struct TestResults {
int m_nx;
int m_ny;
std::string m_file_format;
bool m_data_type;
double m_create_data_time;
double m_read_time;
double m_write_time;
double m_biggest_diff;
};
bool test_io(int nx, int ny, bool random_data, const std::string& ext);
std::unique_ptr<OutputData<double>> createData(int nx, int ny, bool fill = false);
double biggest_difference(const OutputData<double>& data, const OutputData<double>& ref);
std::string report() const;
std::vector<TestResults> m_test_results;
};
#endif // COREIOTEST_H
......@@ -600,3 +600,15 @@
# before release 1.8
| 2017-04-06 10:10:45 | scgsun | Linux x86_64 | 2.7 | 92.7194 | 14.7865 | 0.3003 | 0.5033 | 3.1531 | 0.3659 | 2.1406 | 0.5124 | 2.5461 | 0.8613 | 2.0314 | 1.5734 | 0.7986 |
| 06.04.2017 10:14:18 | domain2gui 1337 msec | gui2domain 1567 msec | realTime 1284 msec |
# CoreIOTest 2017-06-14
Size | format | data | create read write | diff
1024x768 | int | 0 | 0.003 0.199 0.267 | 2.22507e-308
1024x768 | int.gz | 0 | 0.004 0.226 0.337 | 2.22507e-308
1024x768 | int.bz2 | 0 | 0.001 0.356 3.334 | 2.22507e-308
1024x768 | int | 1 | 0.058 0.279 0.603 | 4.99617e-13
1024x768 | int.gz | 1 | 0.058 0.417 1.608 | 4.97714e-13
1024x768 | int.bz2 | 1 | 0.058 0.759 1.787 | 4.98674e-13
2048x2048 | int | 1 | 0.317 1.451 3.186 | 4.99909e-13
2048x2048 | int.gz | 1 | 0.310 2.065 8.766 | 4.99337e-13
2048x2048 | int.bz2 | 1 | 0.308 3.991 9.425 | 4.99453e-13
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment