mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-16 21:00:14 +00:00
* Remove APIs unavailable in Store in #8349, #8178, #8065 * Add UWP stubs of C runtime functions * Remove UWP incompatible tests from UWP build * Remove incompatible tests from Store * Use UWP stubs in store only * Skip partition check outside of Windows * Remove unused WRL include * Workaround Windows header not including what it uses * Fix precompiled header name clash * Workaround SDK bugs * DXCore workaround in Win7 * Fix warning * Fix more warnings * Bump WinML to target Windows 8 * Fix more warnings * Remove unnecessary workarounds * Remove Desktop only APIs from DML adapter
59 lines
1.6 KiB
C++
59 lines
1.6 KiB
C++
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
#include "lib/Telemetry/pch.h"
|
|
|
|
#include "inc/TelemetryEvent.h"
|
|
|
|
using namespace _winmlt;
|
|
|
|
static uint64_t s_event_id = 0;
|
|
|
|
static const char*
|
|
EventCategoryToString(
|
|
EventCategory category) {
|
|
switch (category) {
|
|
case EventCategory::kModelLoad:
|
|
return "Model load";
|
|
case EventCategory::kSessionCreation:
|
|
return "Session creation";
|
|
case EventCategory::kBinding:
|
|
return "Binding";
|
|
case EventCategory::kEvaluation:
|
|
return "Evaluation";
|
|
default:
|
|
throw std::invalid_argument("category");
|
|
}
|
|
}
|
|
|
|
TelemetryEvent::TelemetryEvent(
|
|
EventCategory category) {
|
|
auto is_provider_enabled =
|
|
TraceLoggingProviderEnabled(
|
|
winml_trace_logging_provider,
|
|
WINEVENT_LEVEL_VERBOSE,
|
|
WINML_PROVIDER_KEYWORD_START_STOP);
|
|
|
|
if (is_provider_enabled) {
|
|
category_ = category;
|
|
event_id_ = InterlockedIncrement(&s_event_id);
|
|
|
|
WinMLTraceLoggingWrite(
|
|
winml_trace_logging_provider,
|
|
"started event",
|
|
TraceLoggingString(EventCategoryToString(category_), "event"),
|
|
TraceLoggingInt64(event_id_.value(), "eventId"),
|
|
TraceLoggingKeyword(WINML_PROVIDER_KEYWORD_START_STOP));
|
|
}
|
|
}
|
|
|
|
TelemetryEvent::~TelemetryEvent() {
|
|
if (event_id_.has_value()) {
|
|
WinMLTraceLoggingWrite(
|
|
winml_trace_logging_provider,
|
|
"stopped event",
|
|
TraceLoggingString(EventCategoryToString(category_), "event"),
|
|
TraceLoggingInt64(event_id_.value(), "eventId"),
|
|
TraceLoggingKeyword(WINML_PROVIDER_KEYWORD_START_STOP));
|
|
}
|
|
}
|