modifié : include/ArrayTree/ArrayTreeBuilder.hpp modifié : include/ArrayTree/ArrayTreeBuilder.tpp modifié : include/ArrayTree/Border.hpp modifié : include/ArrayTree/Border.tpp modifié : include/ArrayTree/GraphWalker.hpp modifié : include/ArrayTree/GraphWalker.tpp modifié : include/ArrayTree/Leader.tpp modifié : include/ArrayTree/triskeleArrayTreeBase.hpp modifié : include/ArrayTree/triskeleArrayTreeBase.tpp modifié : include/AttributeProfiles.hpp modifié : include/AttributeProfiles.tpp modifié : include/Attributes/AreaAttributes.hpp modifié : include/Attributes/AverageAttributes.hpp modifié : include/Attributes/MoIAttributes.hpp modifié : include/Attributes/SDAttributes.hpp modifié : include/Attributes/WeightAttributes.hpp modifié : include/Attributes/XYAttributes.hpp modifié : include/CompAttribute.hpp modifié : include/CompAttribute.tpp modifié : include/Tree.hpp modifié : include/Tree.tpp modifié : include/TreeStats.hpp modifié : include/triskeleBase.hpp modifié : include/triskeleBase.tpp modifié : include/triskeleDebug.hpp modifié : src/Tree.cpp modifié : src/TreeStats.cpp modifié : src/apGenerator.cpp
135 lines
3.6 KiB
C++
135 lines
3.6 KiB
C++
#include <iomanip>
|
|
|
|
#include <boost/chrono.hpp>
|
|
|
|
#include "TreeStats.hpp"
|
|
|
|
using namespace otb::triskele;
|
|
using namespace std;
|
|
|
|
// ========================================
|
|
static string timeTypeLabels [TimeTypeCard] = {
|
|
"build tree",
|
|
"area",
|
|
"average",
|
|
"xy",
|
|
"moi",
|
|
"sd",
|
|
"filtering",
|
|
"copy image",
|
|
"GDAL read",
|
|
"GDAL write",
|
|
"sum All",
|
|
};
|
|
|
|
TreeStats globalTreeStats;
|
|
|
|
// ========================================
|
|
using namespace boost::chrono;
|
|
inline string
|
|
ns2string (double delta) {
|
|
ostringstream oss;
|
|
duration<double> ns (delta);
|
|
oss.fill ('0');
|
|
// typedef duration<int, ratio<86400> > days;
|
|
// auto d = duration_cast<days>(ns);
|
|
// ns -= d;
|
|
auto h = duration_cast<hours> (ns);
|
|
ns -= h;
|
|
auto m = duration_cast<minutes> (ns);
|
|
ns -= m;
|
|
oss << setw (2) << h.count () << ":"
|
|
<< setw (2) << m.count () << ":"
|
|
<< setw (9) << fixed << setprecision (6) << ns.count ();
|
|
return oss.str ();
|
|
}
|
|
|
|
// ----------------------------------------
|
|
TreeStats::CPrintDim::CPrintDim (const TreeStats &treeStats)
|
|
: treeStats (treeStats) {
|
|
}
|
|
ostream &
|
|
TreeStats::CPrintDim::print (ostream &out) const {
|
|
bool empty = true;
|
|
for (unsigned int i = 0; i < TreeTypeCard; ++i)
|
|
if (!(empty = !ba::count (treeStats.leavesStats[i])))
|
|
break;
|
|
if (empty)
|
|
return out;
|
|
print (out, treeStats.leavesStats, "Leaf");
|
|
return print (out, treeStats.compStats, "Comp");
|
|
}
|
|
|
|
ostream &
|
|
TreeStats::CPrintDim::print (ostream &out, const TreeStatsDim stats[], const string &msg) const {
|
|
out << endl
|
|
<< setw (11) << left << msg << "\t"
|
|
<< setw (3) << left << "Count" << "\t"
|
|
<< setw (9) << left << "Mean" << "\t"
|
|
<< setw (9) << left << "Min" << "\t"
|
|
<< setw (9) << left << "Max" << endl;
|
|
for (unsigned int i = 0; i < TreeTypeCard; ++i) {
|
|
if (!ba::count (stats[i]))
|
|
continue;
|
|
out << setw (11) << right << treeTypeLabels [i] << "\t"
|
|
<< setw (3) << ba::count (stats[i]) << "\t"
|
|
<< setw (9) << DimImg (ba::mean (stats[i])) << "\t"
|
|
<< setw (9) << ba::min (stats[i]) << "\t"
|
|
<< setw (9) << ba::max (stats[i])
|
|
<< endl << flush;
|
|
}
|
|
return out;
|
|
}
|
|
|
|
TreeStats::CPrintDim
|
|
TreeStats::printDim () const {
|
|
return CPrintDim (*this);
|
|
}
|
|
// ostream&
|
|
// operator << (ostream& out, const TreeStats::CPrintDim &cpd) {
|
|
// return cpd.print (out);
|
|
// }
|
|
|
|
// ----------------------------------------
|
|
TreeStats::CPrintTime::CPrintTime (const TreeStats &treeStats)
|
|
: treeStats (treeStats) {
|
|
}
|
|
ostream &
|
|
TreeStats::CPrintTime::print (ostream &out) const {
|
|
bool empty = true;
|
|
for (unsigned int i = 0; i < TimeTypeCard; ++i)
|
|
if (!(empty = !ba::count (treeStats.timeStats[i])))
|
|
break;
|
|
if (empty)
|
|
return out;
|
|
out << endl
|
|
<< setw (11) << left << "Time" << "\t"
|
|
<< setw (15) << left << "Sum" << "\t"
|
|
<< setw (3) << left << "Count" << "\t"
|
|
<< setw (15) << left << "Mean" << "\t"
|
|
<< setw (15) << left << "Min" << "\t"
|
|
<< setw (15) << left << "Max" << endl;
|
|
for (unsigned int i = 0; i < TimeTypeCard; ++i) {
|
|
if (!ba::count (treeStats.timeStats[i]))
|
|
continue;
|
|
out << setw (11) << right << timeTypeLabels[i] << "\t"
|
|
<< ns2string (ba::sum (treeStats.timeStats[i])) << "\t" << setw (3) << ba::count (treeStats.timeStats[i]) << "\t"
|
|
<< ns2string (ba::mean (treeStats.timeStats[i])) << "\t"
|
|
<< ns2string (ba::min (treeStats.timeStats[i])) << "\t"
|
|
<< ns2string (ba::max (treeStats.timeStats[i]))
|
|
<< endl << flush;
|
|
}
|
|
return out;
|
|
}
|
|
|
|
TreeStats::CPrintTime
|
|
TreeStats::printTime () const {
|
|
return CPrintTime (*this);
|
|
}
|
|
// ostream&
|
|
// operator << (ostream& out, const TreeStats::CPrintTime &cpt) {
|
|
// return cpt.print (out);
|
|
// }
|
|
|
|
// ========================================
|