Skip to content

Commit

Permalink
Added some profilling macros into GCodeTimeEstimator
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmatena committed Jul 20, 2018
1 parent 95bd2bb commit 167060e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
3 changes: 3 additions & 0 deletions xs/src/Shiny/ShinyPrereqs.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ THE SOFTWARE.
#ifndef SHINY_PREREQS_H
#define SHINY_PREREQS_H


#include <stdint.h>

/*---------------------------------------------------------------------------*/

#ifndef FALSE
Expand Down
5 changes: 4 additions & 1 deletion xs/src/Shiny/ShinyTools.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,11 @@ float ShinyGetTickInvFreq(void) {

#elif SHINY_PLATFORM == SHINY_PLATFORM_POSIX

//#include <time.h>
//#include <sys/time.h>

void ShinyGetTicks(shinytick_t *p) {
timeval time;
struct timeval time;
gettimeofday(&time, NULL);

*p = time.tv_sec * 1000000 + time.tv_usec;
Expand Down
27 changes: 27 additions & 0 deletions xs/src/libslic3r/GCodeTimeEstimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ namespace Slic3r {

GCodeFlavor GCodeTimeEstimator::get_dialect() const
{
PROFILE_FUNC();
return _state.dialect;
}

Expand Down Expand Up @@ -536,6 +537,7 @@ namespace Slic3r {

void GCodeTimeEstimator::add_additional_time(float timeSec)
{
PROFILE_FUNC();
_state.additional_time += timeSec;
}

Expand Down Expand Up @@ -627,8 +629,10 @@ namespace Slic3r {
_blocks.clear();
}


void GCodeTimeEstimator::_calculate_time()
{
PROFILE_FUNC();
_forward_pass();
_reverse_pass();
_recalculate_trapezoids();
Expand Down Expand Up @@ -797,6 +801,7 @@ namespace Slic3r {

void GCodeTimeEstimator::_processG1(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
increment_g1_line_id();

// updates axes positions from line
Expand Down Expand Up @@ -994,6 +999,7 @@ namespace Slic3r {

void GCodeTimeEstimator::_processG4(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
GCodeFlavor dialect = get_dialect();

float value;
Expand All @@ -1015,31 +1021,37 @@ namespace Slic3r {

void GCodeTimeEstimator::_processG20(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
set_units(Inches);
}

void GCodeTimeEstimator::_processG21(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
set_units(Millimeters);
}

void GCodeTimeEstimator::_processG28(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
// TODO
}

void GCodeTimeEstimator::_processG90(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
set_global_positioning_type(Absolute);
}

void GCodeTimeEstimator::_processG91(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
set_global_positioning_type(Relative);
}

void GCodeTimeEstimator::_processG92(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
float lengthsScaleFactor = (get_units() == Inches) ? INCHES_TO_MM : 1.0f;
bool anyFound = false;

Expand Down Expand Up @@ -1080,26 +1092,31 @@ namespace Slic3r {

void GCodeTimeEstimator::_processM1(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
_simulate_st_synchronize();
}

void GCodeTimeEstimator::_processM82(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
set_e_local_positioning_type(Absolute);
}

void GCodeTimeEstimator::_processM83(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
set_e_local_positioning_type(Relative);
}

void GCodeTimeEstimator::_processM109(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
// TODO
}

void GCodeTimeEstimator::_processM201(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
GCodeFlavor dialect = get_dialect();

// see http://reprap.org/wiki/G-code#M201:_Set_max_printing_acceleration
Expand All @@ -1120,6 +1137,7 @@ namespace Slic3r {

void GCodeTimeEstimator::_processM203(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
GCodeFlavor dialect = get_dialect();

// see http://reprap.org/wiki/G-code#M203:_Set_maximum_feedrate
Expand All @@ -1144,6 +1162,7 @@ namespace Slic3r {

void GCodeTimeEstimator::_processM204(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
float value;
if (line.has_value('S', value))
set_acceleration(value);
Expand All @@ -1154,6 +1173,7 @@ namespace Slic3r {

void GCodeTimeEstimator::_processM205(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
if (line.has_x())
{
float max_jerk = line.x();
Expand All @@ -1180,6 +1200,7 @@ namespace Slic3r {

void GCodeTimeEstimator::_processM221(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
float value_s;
float value_t;
if (line.has_value('S', value_s) && !line.has_value('T', value_t))
Expand All @@ -1188,6 +1209,7 @@ namespace Slic3r {

void GCodeTimeEstimator::_processM566(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
if (line.has_x())
set_axis_max_jerk(X, line.x() * MMMIN_TO_MMSEC);

Expand All @@ -1203,11 +1225,13 @@ namespace Slic3r {

void GCodeTimeEstimator::_simulate_st_synchronize()
{
PROFILE_FUNC();
_calculate_time();
}

void GCodeTimeEstimator::_forward_pass()
{
PROFILE_FUNC();
if (_blocks.size() > 1)
{
for (int i = _last_st_synchronized_block_id + 1; i < (int)_blocks.size() - 1; ++i)
Expand All @@ -1219,6 +1243,7 @@ namespace Slic3r {

void GCodeTimeEstimator::_reverse_pass()
{
PROFILE_FUNC();
if (_blocks.size() > 1)
{
for (int i = (int)_blocks.size() - 1; i >= _last_st_synchronized_block_id + 2; --i)
Expand All @@ -1230,6 +1255,7 @@ namespace Slic3r {

void GCodeTimeEstimator::_planner_forward_pass_kernel(Block& prev, Block& curr)
{
PROFILE_FUNC();
// If the previous block is an acceleration block, but it is not long enough to complete the
// full speed change within the block, we need to adjust the entry speed accordingly. Entry
// speeds have already been reset, maximized, and reverse planned by reverse planner.
Expand Down Expand Up @@ -1270,6 +1296,7 @@ namespace Slic3r {

void GCodeTimeEstimator::_recalculate_trapezoids()
{
PROFILE_FUNC();
Block* curr = nullptr;
Block* next = nullptr;

Expand Down
4 changes: 2 additions & 2 deletions xs/src/libslic3r/PrintObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1183,8 +1183,8 @@ void PrintObject::_slice()

this->typed_slices = false;

#if 0
// Disable parallelization for debugging purposes.
#ifdef SLIC3R_PROFILE
// Disable parallelization so the Shiny profiler works
static tbb::task_scheduler_init *tbb_init = nullptr;
tbb_init = new tbb::task_scheduler_init(1);
#endif
Expand Down

0 comments on commit 167060e

Please sign in to comment.