Performance counters
-
im using a performance counter to monitor my bandwidth but its not displaying like it does in performance monitor in my code it jumps from 0 to a 34523452(positive) number to a -45735399negittive) number in performance monitor it runs steady with what azureus says im uploading at when azureus says upload is around 226 KB/s performance monitor says around 244000 bytes/s here is the code that seems to not be right its running on a 1 sec timer PDH_FMT_COUNTERVALUE fmtValue;
pdhStatus = PdhCollectQueryData(hQuery); if (ERROR_SUCCESS != pdhStatus) { ErrorExit("PdhCollectQueryData"); cleanup(); } pdhStatus = PdhCollectQueryData(hQuery); pdhStatus = PdhGetFormattedCounterValue (hCounter, PDH_FMT_DOUBLE, &ctrType, &fmtValue); if (pdhStatus == ERROR_SUCCESS) { sentinfo.Empty(); sentinfo.Format("%.3d", fmtValue.doubleValue); GetDlgItem(IDC_SENT)->SetWindowText(sentinfo); UpdateWindow(); } else { ErrorExit("PdhGetFormattedCounterValue"); cleanup(); } MSG msg; if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); }
if you see what aint right please let me know. -
im using a performance counter to monitor my bandwidth but its not displaying like it does in performance monitor in my code it jumps from 0 to a 34523452(positive) number to a -45735399negittive) number in performance monitor it runs steady with what azureus says im uploading at when azureus says upload is around 226 KB/s performance monitor says around 244000 bytes/s here is the code that seems to not be right its running on a 1 sec timer PDH_FMT_COUNTERVALUE fmtValue;
pdhStatus = PdhCollectQueryData(hQuery); if (ERROR_SUCCESS != pdhStatus) { ErrorExit("PdhCollectQueryData"); cleanup(); } pdhStatus = PdhCollectQueryData(hQuery); pdhStatus = PdhGetFormattedCounterValue (hCounter, PDH_FMT_DOUBLE, &ctrType, &fmtValue); if (pdhStatus == ERROR_SUCCESS) { sentinfo.Empty(); sentinfo.Format("%.3d", fmtValue.doubleValue); GetDlgItem(IDC_SENT)->SetWindowText(sentinfo); UpdateWindow(); } else { ErrorExit("PdhGetFormattedCounterValue"); cleanup(); } MSG msg; if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); }
if you see what aint right please let me know. -
Since
fmtValue.doubleValue
is a float value, I do not think the "%d
" format specifier is appropriate. You should try "%f
" or "%g
":sentinfo.Format( "%.3f", fmtValue.doubleValue);
I hope this helps.