File: Scoped_timer_test.cpp

package info (click to toggle)
megacmd 2.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 32,592 kB
  • sloc: cpp: 326,437; ansic: 34,524; python: 4,630; java: 3,965; sh: 2,869; objc: 2,459; makefile: 197; xml: 113
file content (18 lines) | stat: -rw-r--r-- 614 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "gtest/gtest.h"
#include "mega/scoped_timer.h"
#include <thread>
#include <chrono>

using mega::ScopedSteadyTimer;
using namespace std::chrono_literals;

TEST(ScopedTimer, ScopedSteadyTimerMeasurePassedTimeCorrectly)
{
    ScopedSteadyTimer timer;
    // sleep_for blocks the execution of the current thread for at least the specified
    // sleep_duration. It may block for longer than sleep_duration due to scheduling or resource
    // contention delays.
    std::this_thread::sleep_for(1000ms);
    auto duration = timer.passedTime();
    ASSERT_GE(duration, 1000ms); // Never could be less that 1s
}