Skip to content

Commit

Permalink
feat(Timer): provide access to duration in raw format
Browse files Browse the repository at this point in the history
  • Loading branch information
yo35 committed Sep 6, 2024
1 parent 28cff40 commit 703d824
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions include/geode/basic/timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#pragma once

#include <absl/time/time.h>

#include <geode/basic/common.hpp>
#include <geode/basic/pimpl.hpp>

Expand All @@ -35,6 +37,8 @@ namespace geode
Timer( Timer&& other ) noexcept;
~Timer();

absl::Duration raw_duration() const;

std::string duration() const;

void reset();
Expand Down
12 changes: 11 additions & 1 deletion src/geode/basic/timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ namespace geode
reset();
}

absl::Duration raw_duration() const
{
return absl::Now() - start_time_;
}

std::string duration() const
{
return absl::FormatDuration( absl::Now() - start_time_ );
return absl::FormatDuration( raw_duration() );
}

void reset()
Expand All @@ -57,6 +62,11 @@ namespace geode

Timer::~Timer() = default;

absl::Duration Timer::raw_duration() const
{
return impl_->raw_duration();
}

std::string Timer::duration() const
{
return impl_->duration();
Expand Down

0 comments on commit 703d824

Please sign in to comment.