Skip to content

Commit 76b7748

Browse files
committed
Note some time points #4915
1 parent a2334f4 commit 76b7748

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

src/ifcgeom/Iterator.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ namespace IfcGeom {
155155
// Should not be destructed because, destructor is blocking
156156
std::future<void> init_future_;
157157

158+
std::array<std::chrono::high_resolution_clock::time_point, 4> time_points;
159+
158160
/// @todo public/private sections all over the place: move all public to the beginning of the class
159161
public:
160162
void set_cache(GeometrySerializer* cache) { cache_ = cache; }
@@ -165,17 +167,21 @@ namespace IfcGeom {
165167
boost::optional<bool> initialization_outcome_;
166168

167169
bool initialize() {
170+
using std::chrono::high_resolution_clock;
171+
168172
if (initialization_outcome_) {
169173
return *initialization_outcome_;
170174
}
171175

176+
time_points[0] = high_resolution_clock::now();
172177
converter_ = new ifcopenshell::geometry::Converter(geometry_library_, ifc_file, settings_);
173178
std::vector<ifcopenshell::geometry::geometry_conversion_task> reps;
174179
if (num_threads_ != 1) {
175180
// @todo this shouldn't be necessary with properly immutable taxonomy items
176181
converter_->mapping()->use_caching() = false;
177182
}
178183
converter_->mapping()->get_representations(reps, filters_);
184+
time_points[1] = high_resolution_clock::now();
179185

180186
for (auto& task : reps) {
181187
geometry_conversion_result res;
@@ -195,6 +201,8 @@ namespace IfcGeom {
195201
num_products += r.products.size();
196202
}
197203

204+
time_points[2] = high_resolution_clock::now();
205+
198206
/*
199207
// What to do, map representation and product individually?
200208
// There needs to be two options, mapped item respecting (does that still work?), and optimized based on topology sorting.
@@ -569,6 +577,24 @@ namespace IfcGeom {
569577
}
570578
}
571579

580+
void log_timepoints() const {
581+
using std::chrono::high_resolution_clock;
582+
using std::chrono::duration;
583+
using namespace std::string_literals;
584+
585+
std::array<std::string, 3> labels = {
586+
"Initializing mapping"s,
587+
"Performing mapping"s,
588+
"Geometry interpretation"s
589+
};
590+
591+
for (auto it = time_points.begin() + 1; it != time_points.end(); ++it) {
592+
auto jt = it - 1;
593+
duration<double, std::milli> ms_double = (*it) - (*jt);
594+
Logger::Notice(labels[std::distance(time_points.begin(), jt)] + " took " + std::to_string(ms_double.count()) + "ms");
595+
}
596+
}
597+
572598
public:
573599
/// Returns what would be the product for the next shape representation
574600
/// @todo Double-check and test the impl.
@@ -587,8 +613,12 @@ namespace IfcGeom {
587613
/// Moves to the next shape representation, create its geometry, and returns the associated product.
588614
/// Use get() to retrieve the created geometry.
589615
const IfcUtil::IfcBaseClass* next() {
616+
using std::chrono::high_resolution_clock;
590617
if (num_threads_ != 1) {
591618
if (!wait_for_element()) {
619+
Logger::SetProduct(boost::none);
620+
time_points[3] = high_resolution_clock::now();
621+
log_timepoints();
592622
return nullptr;
593623
}
594624

@@ -602,6 +632,8 @@ namespace IfcGeom {
602632
if (task_result_iterator_ == --all_processed_elements_.end()) {
603633
if (!create()) {
604634
Logger::SetProduct(boost::none);
635+
time_points[3] = high_resolution_clock::now();
636+
log_timepoints();
605637
return nullptr;
606638
}
607639
}

0 commit comments

Comments
 (0)