mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-22 07:01:30 +00:00
[idd] logging: make periodic statistics opt-in
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "capture/CFrameScheduler.h"
|
||||
|
||||
#include "config/CSettings.h"
|
||||
#include "CDebug.h"
|
||||
#include "Seq.h"
|
||||
|
||||
@@ -992,6 +993,9 @@ void CFrameScheduler::LogStatistics(uint64_t now)
|
||||
m_lastLogPublished = m_publishedFrames;
|
||||
lock.Unlock();
|
||||
|
||||
if (!g_settings.ShouldLogStatistics())
|
||||
return;
|
||||
|
||||
const double acquiredRate =
|
||||
static_cast<double>(acquired) * 1000000000.0 / elapsed;
|
||||
DEBUG_TRACE("Frame schedule owner %u: %.3f Hz client, %.3f Hz acquired, "
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
|
||||
CSettings g_settings;
|
||||
|
||||
#define LGIDD_REGKEY L"SOFTWARE\\LookingGlass\\IDD"
|
||||
|
||||
CSettings::CSettings()
|
||||
{
|
||||
}
|
||||
@@ -107,7 +105,7 @@ bool CSettings::SetExtraMode(const DisplayMode& mode)
|
||||
DWORD disp = 0;
|
||||
LONG ec = RegCreateKeyExW(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
LGIDD_REGKEY,
|
||||
RegistryKey(),
|
||||
0, NULL, REG_OPTION_NON_VOLATILE,
|
||||
KEY_SET_VALUE,
|
||||
NULL, &hKey, &disp);
|
||||
@@ -142,7 +140,7 @@ std::wstring CSettings::ReadStringValue(const wchar_t* name, const wchar_t* defa
|
||||
HKEY hKey = nullptr;
|
||||
LONG ec = RegOpenKeyExW(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
LGIDD_REGKEY,
|
||||
RegistryKey(),
|
||||
0,
|
||||
KEY_QUERY_VALUE,
|
||||
&hKey
|
||||
@@ -188,51 +186,6 @@ std::wstring CSettings::ReadStringValue(const wchar_t* name, const wchar_t* defa
|
||||
return std::wstring(buf.data());
|
||||
}
|
||||
|
||||
bool CSettings::ReadBoolValue(const wchar_t* name, bool defaultValue)
|
||||
{
|
||||
HKEY hKey = nullptr;
|
||||
LONG ec = RegOpenKeyExW(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
LGIDD_REGKEY,
|
||||
0,
|
||||
KEY_QUERY_VALUE,
|
||||
&hKey
|
||||
);
|
||||
|
||||
if (ec != ERROR_SUCCESS)
|
||||
return defaultValue;
|
||||
|
||||
DWORD type = 0;
|
||||
DWORD cb = 0;
|
||||
|
||||
ec = RegQueryValueExW(hKey, name, nullptr, &type, nullptr, &cb);
|
||||
if (ec != ERROR_SUCCESS || type != REG_DWORD || cb != sizeof(DWORD))
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
DWORD value = 0;
|
||||
DWORD type2 = 0;
|
||||
DWORD cb2 = sizeof(value);
|
||||
|
||||
ec = RegQueryValueExW(
|
||||
hKey,
|
||||
name,
|
||||
nullptr,
|
||||
&type2,
|
||||
reinterpret_cast<LPBYTE>(&value),
|
||||
&cb2
|
||||
);
|
||||
|
||||
RegCloseKey(hKey);
|
||||
|
||||
if (ec != ERROR_SUCCESS || type2 != REG_DWORD || cb2 != sizeof(DWORD))
|
||||
return defaultValue;
|
||||
|
||||
return value != 0;
|
||||
}
|
||||
|
||||
bool CSettings::GetExtraMode(DisplayMode& mode)
|
||||
{
|
||||
std::wstring extraMode = ReadStringValue(L"ExtraMode", NULL);
|
||||
@@ -250,7 +203,7 @@ unsigned CSettings::GetDefaultRefreshMilliHz() const
|
||||
{
|
||||
HKEY hKey = nullptr;
|
||||
LONG status = RegOpenKeyExW(
|
||||
HKEY_LOCAL_MACHINE, LGIDD_REGKEY, 0, KEY_QUERY_VALUE, &hKey);
|
||||
HKEY_LOCAL_MACHINE, RegistryKey(), 0, KEY_QUERY_VALUE, &hKey);
|
||||
if (status != ERROR_SUCCESS)
|
||||
return 60000;
|
||||
|
||||
@@ -291,7 +244,8 @@ bool CSettings::ReadMultiStringValue(const wchar_t * name,
|
||||
std::vector<std::wstring>& out) const
|
||||
{
|
||||
HKEY hKey = nullptr;
|
||||
LONG st = RegOpenKeyExW(HKEY_LOCAL_MACHINE, LGIDD_REGKEY, 0, KEY_QUERY_VALUE, &hKey);
|
||||
LONG st = RegOpenKeyExW(
|
||||
HKEY_LOCAL_MACHINE, RegistryKey(), 0, KEY_QUERY_VALUE, &hKey);
|
||||
if (st != ERROR_SUCCESS)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -47,9 +47,61 @@ class CSettings
|
||||
unsigned GetDefaultRefreshMilliHz() const;
|
||||
|
||||
std::wstring ReadStringValue(const wchar_t* name, const wchar_t* defaultValue = nullptr);
|
||||
bool ReadBoolValue(const wchar_t* name, bool defaultValue = false);
|
||||
static bool ReadBoolValue(
|
||||
const wchar_t * name, bool defaultValue = false)
|
||||
{
|
||||
HKEY hKey = nullptr;
|
||||
LONG status = RegOpenKeyExW(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
RegistryKey(),
|
||||
0,
|
||||
KEY_QUERY_VALUE,
|
||||
&hKey);
|
||||
if (status != ERROR_SUCCESS)
|
||||
return defaultValue;
|
||||
|
||||
DWORD type = 0;
|
||||
DWORD size = 0;
|
||||
status = RegQueryValueExW(
|
||||
hKey, name, nullptr, &type, nullptr, &size);
|
||||
if (status != ERROR_SUCCESS ||
|
||||
type != REG_DWORD ||
|
||||
size != sizeof(DWORD))
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
DWORD value = 0;
|
||||
DWORD valueType = 0;
|
||||
DWORD valueSize = sizeof(value);
|
||||
status = RegQueryValueExW(
|
||||
hKey,
|
||||
name,
|
||||
nullptr,
|
||||
&valueType,
|
||||
reinterpret_cast<LPBYTE>(&value),
|
||||
&valueSize);
|
||||
RegCloseKey(hKey);
|
||||
if (status != ERROR_SUCCESS ||
|
||||
valueType != REG_DWORD ||
|
||||
valueSize != sizeof(value))
|
||||
return defaultValue;
|
||||
|
||||
return value != 0;
|
||||
}
|
||||
|
||||
static bool ShouldLogStatistics()
|
||||
{
|
||||
return ReadBoolValue(L"LogStatistics");
|
||||
}
|
||||
|
||||
private:
|
||||
static const wchar_t * RegistryKey()
|
||||
{
|
||||
return L"SOFTWARE\\LookingGlass\\IDD";
|
||||
}
|
||||
|
||||
bool ReadMultiStringValue(const wchar_t * name,
|
||||
std::vector<std::wstring>& out) const;
|
||||
bool ReadModesValue(std::vector<std::wstring> &out) const;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "ipc/CInputPipeServer.h"
|
||||
|
||||
#include "config/CSettings.h"
|
||||
#include "CDebug.h"
|
||||
#include "CSRWLock.h"
|
||||
#include "InputPipeProtocol.h"
|
||||
@@ -505,6 +506,9 @@ void CInputPipeServer::LogStatistics()
|
||||
resyncDiscarded || sent || stale || writeFailed || slowWrites))
|
||||
return;
|
||||
|
||||
if (!g_settings.ShouldLogStatistics())
|
||||
return;
|
||||
|
||||
const double writeMs = m_performanceFrequency.QuadPart ?
|
||||
static_cast<double>(writeTicks) * 1000.0 /
|
||||
m_performanceFrequency.QuadPart : 0.0;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "transport/lgmp/CLGMPInputTransport.h"
|
||||
|
||||
#include "config/CSettings.h"
|
||||
#include "transport/lgmp/CLGMPHost.h"
|
||||
#include "Atomic.h"
|
||||
#include "CDebug.h"
|
||||
@@ -644,6 +645,9 @@ void CLGMPInputTransport::LogStatistics(ULONGLONG now)
|
||||
!statistics.releases && !statistics.deliveryFailures)
|
||||
return;
|
||||
|
||||
if (!g_settings.ShouldLogStatistics())
|
||||
return;
|
||||
|
||||
const double elapsed =
|
||||
static_cast<double>(now - statistics.lastLog) / 1000.0;
|
||||
DEBUG_TRACE("LGMP input host: %.1f msg/s, %llu reports, "
|
||||
|
||||
Reference in New Issue
Block a user