//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF //// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO //// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A //// PARTICULAR PURPOSE. //// //// Copyright (c) Microsoft Corporation. All rights reserved #pragma once #include "ChatManagerSettings.h" #if TV_API namespace Microsoft { namespace Xbox { namespace GameChat { public ref class ChatPerformanceTime sealed { public: /// /// Minimum time value in milliseconds. // Defaults to 100000.0ms until the first audio thread update /// property double MinTimeInMilliseconds { double get(); } /// /// Maximum time value in milliseconds. // Defaults to 0.0ms until the first audio thread update /// property double MaxTimeInMilliseconds { double get(); } /// /// Rolling average time value in milliseconds. /// Value is refreshed every 500ms while the audio thread executes. // Defaults to 0.0ms until the first audio thread update. /// property double AverageTimeInMilliseconds { double get(); } internal: ChatPerformanceTime(); void Update( _In_ double executeTimeInMilliseconds, _In_ double timePassedInMilliseconds ); private: Concurrency::critical_section m_stateLock; double m_minTimeInMilliseconds; double m_maxTimeInMilliseconds; double m_averageTimeInMilliseconds; double m_totalTimeInMilliseconds; double m_totalExecutionTimeInMilliseconds; long m_counter; }; public ref class ChatPerformanceCounters sealed { public: /// /// ChatPerformanceTime object representing time spent capturing chat data /// property ChatPerformanceTime^ CaptureExecutionTime { ChatPerformanceTime^ get(); } /// /// ChatPerformanceTime object representing time spent sending chat data /// property ChatPerformanceTime^ SendExecutionTime { ChatPerformanceTime^ get(); } /// /// ChatPerformanceTime object representing time spent rendering incoming chat data /// property ChatPerformanceTime^ RenderExecutionTime { ChatPerformanceTime^ get(); } /// /// ChatPerformanceTime object representing time spent executing the audio worker thread /// property ChatPerformanceTime^ AudioThreadExecutionTime { ChatPerformanceTime^ get(); } /// /// ChatPerformanceTime object representing how often the audio thread wakes to do work /// property ChatPerformanceTime^ AudioThreadPeriodTime { ChatPerformanceTime^ get(); } /// /// ChatPerformanceTime object representing the time it takes to process incoming packets /// property ChatPerformanceTime^ IncomingPacketTime { ChatPerformanceTime^ get(); } /// /// Returns the bandwidth in bits per second of incoming packets /// property double IncomingPacketBandwidthBitsPerSecond { double get(); } /// /// Returns the bandwidth in bits per second of outgoing packets /// property double OutgoingPacketBandwidthBitsPerSecond { double get(); } internal: ChatPerformanceCounters(); void QueryLoopStart(); void QueryCaptureDone(); void QuerySendDone(); void QueryLoopDone(); void CalculateTimes(); void QueryIncomingPacketStart(); void QueryIncomingPacketDone(); void AddPacketBandwidth( _In_ bool incomingPacket, _In_ int numberOfBytes ); private: void UpdatePacketBandwidth( _In_ double totalTimePassedInMilliseconds ); static double GetDeltaInMilliseconds( _In_ const LARGE_INTEGER& startTime, _In_ const LARGE_INTEGER& endTime, _In_ const LARGE_INTEGER& freq ); LARGE_INTEGER m_freq; LARGE_INTEGER m_loopStartTime; LARGE_INTEGER m_captureDoneTime; LARGE_INTEGER m_sendDoneTime; LARGE_INTEGER m_loopDoneTime; LARGE_INTEGER m_previousLoopStartTime; LARGE_INTEGER m_incomingPacketStartTime; LARGE_INTEGER m_incomingPacketDoneTime; ChatPerformanceTime^ m_captureExecutionTime; ChatPerformanceTime^ m_sendExecutionTime; ChatPerformanceTime^ m_renderExecutionTime; ChatPerformanceTime^ m_audioThreadExecutionTime; ChatPerformanceTime^ m_audioThreadPeriodTime; ChatPerformanceTime^ m_incomingPacketTime; Concurrency::critical_section m_packetBytesLock; int m_incomingPacketBytesIncomingCounter; int m_outgoingPacketBytesIncomingCounter; double m_packetsBytesTimeCounterInMilliseconds; double m_incomingPacketBandwidthBitsPerSecond; double m_outgoingPacketBandwidthBitsPerSecond; }; }}} #endif