Article View: free.pl.comp.games.development
Article #3370Re: Performance Timer [bylo: Hehe, sam nie wiem na jaki to jest temat ;))]
From: robal
Date: Thu, 31 May 2001 08:19
Date: Thu, 31 May 2001 08:19
156 lines
6747 bytes
6747 bytes
> Niestety, nic wiecej nie udalo mi sie na ten temat znalezc w
> MSDN`ie.. Moze dlatego, ze moja wersja jest z przed 4 lat :(
> So, bylbym bardzo wdzieczny, gdybys poszukal i wyjasnil kiedy,
> co, jak, i dlaczego nie dziala.
Sorry za wielkosc, bedzie przedruk z MSDN'a... ;-))
SYMPTOMS
The result that is returned by the QueryPerformanceCounter function may
unexpectedly leap forward from time to time. This leap may represent several
seconds.
CAUSE
This problem occurs as a result of a design defect in the peripheral
component interconnect (PCI) to Industry Standard Architecture (ISA) bridge
of some chipsets. This bridge is commonly referred to as the south bridge.
The jump occurs under a heavy PCI bus load, when the operating system
receives a series of unexpected results from the bridge. The operating
system detects the unexpected results and computes an amount to add to the
performance counter. This causes the returned result from
QueryPerformanceCounter to jump forward.
RESOLUTION
Programs should watch for an unexpected jump by comparing the change in time
as determined by successive calls to QueryPerformanceCounter with the change
in time as determined by successive calls to the GetTickCount function. If
there is a significant jump that is based on QueryPerformanceCounter(), but
no similar increase that is based on GetTickCount, then it can be assumed
that the performance counter just jumped forward. The code sample at the end
of this article demonstrates how to do this.
STATUS
This operating system's behavior is by design. The performance counter
adjustment is necessary when the operating system obtains unreliable data
from the chipset.
MORE INFORMATION
Design defects within a hardware chip are known as errata. These design
defects may cause the product to deviate from published specifications. For
information on errata in specific chipsets, please contact the hardware
vendor for the chipset.
A machine's PCI components are identified by a PCI identifier within the
following key in the Windows registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI
The names of subkeys have the following form
VEN_xxxx&DEV_yyyy&SUBSYS_aaaaaaaa&REV_bb
where xxxx:yyyy represents the PCI identifier.
Currently, chips with the following PCI identifiers are known to exhibit a
jump in performance counter value:
PCI ID Hardware Vendor
1039:0530 Silicon Integrated Systems (SiS)
1039:0620 Silicon Integrated Systems (SiS)
10B9:0533 Acer Labs, Inc. (ALi)
10B9:1533 Acer Labs, Inc. (ALi)
1106:0596 VIA Technologies, Inc. (VIA)
1106:0686 VIA Technologies, Inc. (VIA)
1166:004F Serverworks Corporation
1166:0050 Serverworks Corporation
8086:7110 Intel Corporation
This list will be updated as Microsoft observes the behavior in other
chipsets.
Sample Code
The following sample code demonstrates the method described above for
detecting performance counter leaps. If the code is run on a computer with
the PIIX4 chipset, for example, this console application will sporadically
report leaps in the performance counter value.
#include <windows.h>
#include <stdio.h>
void main() {
LARGE_INTEGER liFrequency;
LARGE_INTEGER liCurrent;
LARGE_INTEGER liLast;
LARGE_INTEGER liRecent[10];
DWORD dwCurrent;
DWORD dwLast;
DWORD dwPerfElapsed;
DWORD dwTickElapsed;
int i = 0;
int j;
// Save the performance counter frequency for later use.
if (!QueryPerformanceFrequency(&liFrequency))
printf("QPF() failed with error %d\n", GetLastError());
// Query the performance counter value and tick count.
dwCurrent = GetTickCount();
if (!QueryPerformanceCounter(&liCurrent))
printf("QPC() failed with error %d\n", GetLastError());
liLast = liCurrent;
dwLast = dwCurrent;
while (TRUE) {
// Query the performance counter value and tick count.
if (!QueryPerformanceCounter(&liCurrent))
printf("QPC() failed with error %d\n", GetLastError());
dwCurrent = GetTickCount();
// Store the performance counter value in the list of recent values.
liRecent[i].QuadPart = liCurrent.QuadPart;
i = (i+1) % 10;
// Convert difference in performance counter values to milliseconds.
dwPerfElapsed = (DWORD) (((liCurrent.QuadPart - liLast.QuadPart)
* 1000) / liFrequency.QuadPart);
dwTickElapsed = dwCurrent - dwLast;
// Check for a discrepancy greater than 500 milliseconds.
if (abs(dwPerfElapsed - dwTickElapsed) > 500)
// Print the previous 9 performance-counter values.
for (j=9; j>0; j--) {
printf(" Previous %d: %I64X\n", j, liRecent[i].QuadPart);
i = (i+1) % 10;
}
// Print the leap value.
printf( "LEAP: Current: %I64X delta = %I64X\n",
liCurrent.QuadPart, liCurrent.QuadPart - liLast.QuadPart);
// Retrieve and print the next 9 performance-counter values.
for (j=1; j<=9; j++) {
QueryPerformanceCounter(&liCurrent);
printf(" Next %d: %I64X\n", j, liCurrent.QuadPart);
liRecent[i].QuadPart = liCurrent.QuadPart;
i = (i+1) % 10;
}
printf("\n");
}
liLast = liCurrent;
dwLast = dwCurrent;
}
return;
}
bye, robal
**********************
Space - the final frontier
Gene Rodenbery - Star Trek
home site: http://directx.w.interia.pl
**********************
Technical Details
Message-ID:
<9f4usk$lpk$1@news.tpi.pl>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!isdnet!fr.clara.net!heighliner.fr.clara.net!news.tpi.pl!not-for-mailReferences:
<mr38ht4qddg0l6n98ck487fg42omokpno5@4ax.com> <9f27cj$iu8$1@news.tpi.pl> <9f49t5$5ae$1@news.tpi.pl> <9f4oah$ebj$1@news.tpi.pl> <9f4ogd$fdf$1@news.tpi.pl> <9f4u8u$i3k$1@news.tpi.pl>Show Full Headers
Complete Article Headers
X-Google-Language: SLOVAK,ASCII-7-bit X-Google-Thread: 1162ab,2756237bb73fa372 X-Google-Attributes: gid1162ab,public X-Google-ArrivalTime: 2001-05-31 01:19:13 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!isdnet!fr.clara.net!heighliner.fr.clara.net!news.tpi.pl!not-for-mail From: "robal" <directx@interia.pl> Newsgroups: free.pl.comp.games.development Subject: Re: Performance Timer [bylo: Hehe, sam nie wiem na jaki to jest temat ;))] Date: Thu, 31 May 2001 10:19:08 +0200 Organization: tp.internet - http://www.tpi.pl Lines: 158 Message-ID: <9f4usk$lpk$1@news.tpi.pl> References: <mr38ht4qddg0l6n98ck487fg42omokpno5@4ax.com> <9f27cj$iu8$1@news.tpi.pl> <9f49t5$5ae$1@news.tpi.pl> <9f4oah$ebj$1@news.tpi.pl> <9f4ogd$fdf$1@news.tpi.pl> <9f4u8u$i3k$1@news.tpi.pl> NNTP-Posting-Host: 195.205.39.155 X-Trace: news.tpi.pl 991297236 22324 195.205.39.155 (31 May 2001 08:20:36 GMT) X-Complaints-To: usenet@tpi.pl NNTP-Posting-Date: 31 May 2001 08:20:36 GMT X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MSMail-Priority: Normal X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400