Skip to content

Commit

Permalink
pw_perf_test: Initialize the timer in the unit test
Browse files Browse the repository at this point in the history
Change-Id: I10f1c82dec007b1351ea7200c86d2d468dc654f7
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/152174
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Reviewed-by: Taylor Cramer <cramertj@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
  • Loading branch information
255 authored and CQ Bot Account committed Jun 16, 2023
1 parent eafb7fd commit c4a7903
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pw_perf_test/timer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ namespace pw::perf_test::internal {
namespace {

TEST(TimerTest, DurationIsPositive) {
ASSERT_TRUE(TimerPrepare());

Timestamp start = GetCurrentTimestamp();
for (volatile int i = 0; i < 1000; i = i + 1) {
}
Timestamp end = GetCurrentTimestamp();
int64_t duration = GetDuration(start, end);
EXPECT_GT(duration, 0);

TimerCleanup();
}

} // namespace
Expand Down

0 comments on commit c4a7903

Please sign in to comment.