Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a constructor to CalculationTime #285

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/calculation_time.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace TrRouting
class CalculationTime {

public:

CalculationTime();
//static CalculationTime algorithmCalculationTime;
long long getDurationMicroseconds();
long long getDurationMicrosecondsNoStop();
Expand Down
24 changes: 21 additions & 3 deletions src/calculation_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
namespace TrRouting
{

CalculationTime::CalculationTime() :
startEpoch(0),
startStepEpoch(0),
endEpoch(0),
endStepEpoch(0),
calculationEpoch() {
//TODO Should we call start() on construction ??
}

long long CalculationTime::getEpoch()
{
calculationEpoch = std::chrono::duration_cast< std::chrono::microseconds >(
Expand All @@ -25,14 +34,20 @@ namespace TrRouting

long long CalculationTime::getDurationMicroseconds()
{
assert(startEpoch && endEpoch && startEpoch >= 0 && endEpoch >= 0 && endEpoch >= startEpoch);
assert(startEpoch && endEpoch);
assert(startEpoch >= 0);
assert(endEpoch >= 0);
assert(endEpoch >= startEpoch);
return endEpoch - startEpoch;
}

long long CalculationTime::getDurationMicrosecondsNoStop()
{
long long actualEpoch {getEpoch()};
assert(startEpoch && actualEpoch && startEpoch >= 0 && actualEpoch >= 0 && actualEpoch >= startEpoch);
assert(startEpoch && actualEpoch);
assert(startEpoch >= 0);
assert(actualEpoch >= 0);
assert(actualEpoch >= startEpoch);
return actualEpoch - startEpoch;
}

Expand All @@ -48,7 +63,10 @@ namespace TrRouting

long long CalculationTime::getStepDurationMicroseconds()
{
assert(startStepEpoch && endStepEpoch && startStepEpoch >= 0 && endStepEpoch >= 0 && endStepEpoch >= startStepEpoch);
assert(startStepEpoch && endStepEpoch);
assert(startStepEpoch >= 0);
assert(endStepEpoch >= 0);
assert(endStepEpoch >= startStepEpoch);
return endStepEpoch - startStepEpoch;
}

Expand Down
Loading