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

feat(Timer): provide access to duration in raw format #1013

Merged
merged 1 commit into from
Sep 6, 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
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
Loading