Skip to content

Commit

Permalink
log as info job processing time
Browse files Browse the repository at this point in the history
  • Loading branch information
Jony01 committed Aug 25, 2022
1 parent 16a84eb commit 2d66607
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/slic3r/GUI/Jobs/PlaterWorker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define PLATERWORKER_HPP

#include <map>
#include <chrono>

#include "Worker.hpp"
#include "BusyCursorJob.hpp"
Expand All @@ -24,6 +25,7 @@ class PlaterWorker: public Worker {
class PlaterJob : public Job {
std::unique_ptr<Job> m_job;
Plater *m_plater;
long long m_process_duration; // [ms]

public:
void process(Ctl &c) override
Expand Down Expand Up @@ -55,12 +57,27 @@ class PlaterWorker: public Worker {
} wctl{c};

CursorSetterRAII busycursor{wctl};

using namespace std::chrono;
steady_clock::time_point process_start = steady_clock::now();
m_job->process(wctl);
steady_clock::time_point process_end = steady_clock::now();
m_process_duration = duration_cast<milliseconds>(process_end - process_start).count();
}

void finalize(bool canceled, std::exception_ptr &eptr) override
{
using namespace std::chrono;
steady_clock::time_point finalize_start = steady_clock::now();
m_job->finalize(canceled, eptr);
steady_clock::time_point finalize_end = steady_clock::now();
long long finalize_duration = duration_cast<milliseconds>(finalize_end - finalize_start).count();

BOOST_LOG_TRIVIAL(info)
<< std::fixed // do not use scientific notations
<< "Job '" << typeid(*m_job).name() << "' "
<< "spend " << m_process_duration + finalize_duration << "ms "
<< "(process " << m_process_duration << "ms + finalize " << finalize_duration << "ms)" << std::endl;

if (eptr) try {
std::rethrow_exception(eptr);
Expand Down

0 comments on commit 2d66607

Please sign in to comment.