Files
compute-runtime/unit_tests/utilities/timer_util_tests.cpp
Filip Hazubski 8b57d28116 clang-format: enable sorting includes
Include files are now grouped and sorted in following order:
1. Header file of the class the current file implements
2. Project files
3. Third party files
4. Standard library

Change-Id: If31af05652184169f7fee1d7ad08f1b2ed602cf0
Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
2019-02-27 11:50:07 +01:00

66 lines
1.2 KiB
C++

/*
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/utilities/timer_util.h"
#include "test.h"
#include "gtest/gtest.h"
#include <algorithm>
using namespace OCLRT;
TEST(TimerTest, Get) {
Timer::setFreq();
Timer timer;
auto loopCount = 100u;
unsigned long long maxDelta = 0;
unsigned long long minDelta = -1;
while (loopCount--) {
timer.start();
timer.end();
unsigned long long currentDelta = timer.get();
maxDelta = std::max(currentDelta, maxDelta);
minDelta = std::min(currentDelta, minDelta);
}
EXPECT_LE(minDelta, 10000u);
//thread switch may cost up to 2s
EXPECT_LE(maxDelta, 2000000000u);
}
TEST(TimerTest, GetStartEnd) {
Timer::setFreq();
Timer timer;
timer.start();
timer.end();
long long start = timer.getStart();
EXPECT_NE(0, start);
long long end = timer.getEnd();
EXPECT_NE(0, end);
EXPECT_GE(end, start);
}
TEST(TimerTest, Assignement) {
Timer::setFreq();
Timer timer1, timer2;
timer1.start();
timer1.end();
timer2 = timer1;
EXPECT_EQ(timer1.getStart(), timer2.getStart());
}