-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add scope time logger w/ ACF_LOG_GPU_TIME option (hack benchmark in u…
…nit test)
- Loading branch information
1 parent
17c2689
commit 0b95cb7
Showing
3 changed files
with
97 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
#!/bin/bash | ||
|
||
TOOLCHAIN=xcode | ||
CONFIG=MinSizeRel | ||
CONFIG=Release | ||
|
||
ARGS=( | ||
--verbose | ||
--toolchain ${TOOLCHAIN} | ||
--config ${CONFIG} | ||
--fwd HUNTER_CONFIGURATION_TYPES=${CONFIG} | ||
ACF_USE_DRISHTI_CACHE=OFF | ||
ACF_BUILD_TESTS=ON | ||
--jobs 8 | ||
) | ||
|
||
#build.py ${ARGS[@]} --install --reconfig ${*} | ||
build.py ${ARGS[@]} --install ${*} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/*! -*-c++-*- | ||
@file timing.h | ||
@author David Hirvonen | ||
@brief Scope based timing macro. | ||
\copyright Copyright 2014-2017 Elucideye, Inc. All rights reserved. | ||
\license{This project is released under the 3 Clause BSD License.} | ||
*/ | ||
|
||
#ifndef __util_core_ScopeTimeLogger_h__ | ||
#define __util_core_ScopeTimeLogger_h__ | ||
|
||
#include "util/acf_util.h" | ||
|
||
#include <chrono> | ||
#include <functional> | ||
|
||
UTIL_NAMESPACE_BEGIN | ||
|
||
class ScopeTimeLogger | ||
{ | ||
using HighResolutionClock = std::chrono::high_resolution_clock; | ||
using TimePoint = HighResolutionClock::time_point; | ||
|
||
public: | ||
template <class Callable> | ||
ScopeTimeLogger(Callable&& logger) | ||
: m_logger(std::forward<Callable>(logger)) | ||
{ | ||
m_tic = HighResolutionClock::now(); | ||
} | ||
|
||
ScopeTimeLogger(ScopeTimeLogger&& other) | ||
: m_logger(std::move(other.m_logger)) | ||
, m_tic(std::move(other.m_tic)) | ||
{ | ||
} | ||
|
||
~ScopeTimeLogger() | ||
{ | ||
auto now = HighResolutionClock::now(); | ||
m_logger(timeDifference(now, m_tic)); | ||
} | ||
|
||
ScopeTimeLogger(const ScopeTimeLogger&) = delete; | ||
void operator=(const ScopeTimeLogger&) = delete; | ||
|
||
static double timeDifference(const TimePoint& a, const TimePoint& b) | ||
{ | ||
return std::chrono::duration_cast<std::chrono::duration<double>>(a - b).count(); | ||
} | ||
|
||
const TimePoint& getTime() const { return m_tic; } | ||
|
||
protected: | ||
std::function<void(double)> m_logger; | ||
TimePoint m_tic; | ||
}; | ||
|
||
UTIL_NAMESPACE_END | ||
|
||
#endif // __util_core_ScopeTimeLogger_h__ |