Import: DXF backend, frontent; add time measurement

This commit is contained in:
Furgo
2025-06-13 04:07:39 +02:00
parent 77e4047871
commit f84ed59a43
4 changed files with 38 additions and 8 deletions

View File

@@ -48,6 +48,7 @@
#endif
#endif
#include <chrono>
#include "dxf/ImpExpDxf.h"
#include "SketchExportHelper.h"
#include <App/Application.h>
@@ -413,7 +414,13 @@ private:
ImpExpDxfRead dxf_file(EncodedName, pcDoc);
dxf_file.setOptionSource(defaultOptions);
dxf_file.setOptions();
auto startTime = std::chrono::high_resolution_clock::now();
dxf_file.DoRead(IgnoreErrors);
auto endTime = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = endTime - startTime;
dxf_file.setImportTime(elapsed.count());
pcDoc->recompute();
return dxf_file.getStatsAsPyObject();
}
@@ -423,7 +430,6 @@ private:
catch (const Base::Exception& e) {
throw Py::RuntimeError(e.what());
}
return Py::None();
}

View File

@@ -862,6 +862,10 @@ public:
{
return m_fail;
}
void setImportTime(double seconds)
{
m_stats.importTimeSeconds = seconds;
}
void
DoRead(bool ignore_errors = false); // this reads the file and calls the following functions
virtual void StartImport()

View File

@@ -46,6 +46,7 @@
#endif
#endif
#include <chrono>
#include "ExportOCAFGui.h"
#include "ImportOCAFGui.h"
#include "OCAFBrowser.h"
@@ -401,7 +402,13 @@ private:
ImpExpDxfReadGui dxf_file(EncodedName, pcDoc);
dxf_file.setOptionSource(defaultOptions);
dxf_file.setOptions();
auto startTime = std::chrono::high_resolution_clock::now();
dxf_file.DoRead(IgnoreErrors);
auto endTime = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = endTime - startTime;
dxf_file.setImportTime(elapsed.count());
pcDoc->recompute();
return dxf_file.getStatsAsPyObject();
}