Files
angle/util/linux/LinuxTimer.cpp
T
Yuly Novikov 9f088621eb Revert "Load entry points dynamically in tests and samples."
This reverts commit 03923558a7.

Reason for revert: fails compilation on Android, ChromeOS and Fuchsia during roll https://chromium-review.googlesource.com/c/chromium/src/+/1392624

Original change's description:
> Load entry points dynamically in tests and samples.
> 
> This CL adds a dynamic loader generator based on XML files. It also
> refactors the entry point generation script to move the XML parsing
> into a helper class.
> 
> Additionally this includes a new GLES 1.0 base header. The new
> header allows for function pointer types and hiding prototypes.
> 
> All tests and samples now load ANGLE dynamically. In the future this
> will be extended to load entry points from the driver directly when
> possible. This will allow us to perform more accurate A/B testing.
> 
> The new build configuration leads to some tests having more warnings
> applied. The CL includes fixes for the new warnings.
> 
> Bug: angleproject:2995
> Change-Id: I6726d4163f7a6e54d2482f094c0a952f59702a05
> Reviewed-on: https://chromium-review.googlesource.com/c/1359516
> Commit-Queue: Jamie Madill <[email protected]>
> Reviewed-by: Shahbaz Youssefi <[email protected]>

[email protected],[email protected],[email protected]

Change-Id: I902bec2d733c2b879be29c02ab52a0b7d4eaa077
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: angleproject:2995
Reviewed-on: https://chromium-review.googlesource.com/c/1392381
Reviewed-by: Yuly Novikov <[email protected]>
Commit-Queue: Yuly Novikov <[email protected]>
2018-12-29 20:46:23 +00:00

63 lines
1.1 KiB
C++

//
// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// LinuxTimer.cpp: Implementation of a high precision timer class on Linux
#include "linux/LinuxTimer.h"
#include <iostream>
LinuxTimer::LinuxTimer()
: mRunning(false)
{
}
namespace
{
uint64_t getCurrentTimeNs()
{
struct timespec currentTime;
clock_gettime(CLOCK_MONOTONIC, &currentTime);
return currentTime.tv_sec * 1'000'000'000llu + currentTime.tv_nsec;
}
} // anonymous namespace
void LinuxTimer::start()
{
mStartTimeNs = getCurrentTimeNs();
mRunning = true;
}
void LinuxTimer::stop()
{
mStopTimeNs = getCurrentTimeNs();
mRunning = false;
}
double LinuxTimer::getElapsedTime() const
{
uint64_t endTimeNs;
if (mRunning)
{
endTimeNs = getCurrentTimeNs();
}
else
{
endTimeNs = mStopTimeNs;
}
return (endTimeNs - mStartTimeNs) * 1e-9;
}
double LinuxTimer::getAbsoluteTime()
{
return getCurrentTimeNs() * 1e-9;
}
Timer *CreateTimer()
{
return new LinuxTimer();
}