onnxruntime/winml/lib/Api.Image/EventTimer.h
Brian Martin 655ffd5d5b
make (de)tensorization events measure level events (#4958)
* make tensorizer events measures

* throttle the events and add a new one SoftwareBitmapToGPUTensorTelemetryEvent

* factor out timing code into a class

* typo

* typo

* move eventimer class into its own header file

* add throttling to detensorization and remove variable timing

* make detensorization events measures as well

* add ConvertGPUTensorToSoftwareBitmapTelemetryEvent event

* de-duplicate event names

* fix comment

* PR feedback
2020-08-28 16:49:32 -07:00

25 lines
619 B
C++

#include "pch.h"
class EventTimer
{
public:
bool Start()
{
auto now = std::chrono::high_resolution_clock::now();
if (!_started ||
std::chrono::duration_cast<std::chrono::microseconds>(now - _startTime).count() > _kDurationBetweenSendingEvents)
{
_started = true;
_startTime = std::chrono::high_resolution_clock::now();
return true;
}
return false;
}
private:
bool _started = false;
std::chrono::steady_clock::time_point _startTime;
constexpr static long long _kDurationBetweenSendingEvents = 1000 * 50; // duration in (us). send an Event every 50 ms;
};