The Platform Builder includes a sample profiling tool, DispPerf, that the display driver writer can use to profile the performance of a display driver. DispPerf builds a table that lists, for each ROP code that is profiled, the frequency count, elapsed time, in microseconds, and average elapsed time, in microseconds, for ROPs handled by the default GPE emulation, by the software emulation library, and by hardware accelerations. To measure these times accurately, DispPerf can be used only on Windows CE–based platforms that support the QueryPerformanceCounter and QueryPerformanceFrequency functions with a recommended resolution of 1 microsecond.
The S3Virge driver demonstrates how to use the profiler for measuring performance of blits and line drawing. The display driver writer may extend the profiler to measure the performance of additional display functions. Source code for DispPerf is in the Platform\Cepc\Drivers\Display\S3virge\Dispperf directory.
The driver starts profiling of blit operations during the call to the BltPrepare function when it calls the DispPerfStart function. The following code example shows how the driver initializes its display function pointer to use the default emulation provided by the GPE.
SCODE
S3Virge::BltPrepare(GPEBltParms *pBltParms)
{
DispPerfStart (pBltParms->rop4);
pBltParms->pBlt = EmulatedBlt; // Catch all.
When the driver is able to handle the ROP with hardware acceleration or software emulation, it changes its display function pointer appropriately. The driver also calls the DispPerfType function to record which type of acceleration is used to handle the ROP. For example, the following code example demonstrates how the driver calls DispPerfType after the driver successfully sets the display function pointer to a hardware-accelerated function.
// Performance Logging Type
if (pBltParms->pBlt != EmulatedBlt) {
DispPerfType(DISPPERF_ACCEL_HARDWARE);
}
When the blit operation completes, the BltComplete function stops profiling with a call to the DispPerfEnd function.
The DO_DISPPERF environment variable controls whether the code to support profiling is compiled into the display driver. Refer to the Sources file for the S3Virge driver to see how the environment variable causes the correct compiler directives to be set.
DispPerf can be invoked from the Command Shell on a Windows CE–based platform, or it can be launched remotely from the Windows CE Debug Shell. The following example shows the command syntax for DispPerf.
dispperf [-c[w*]] [-d [> file]]
The -c option clears the profiler buffer. If the letter “w” appears one or more times following the -c option, DispPerf calls the CreateWindow function that number of times and profiles the resulting display driver operations. The -d option dumps the profiler buffer in tabular form. If the -d option is followed by “>“ plus a file name, the output is written to the named file. Otherwise, it appears on the console where the command was issued.
The following example shows how DispPerf clears its buffer of all profiling infomration.
Dispperf
–cwwwwwd
It then calls the CreateWindow function five times, profiling the performance of the display functions. The following example shows how DispPerf outputs its table of profiling information to the console.
Dispperf
–c Pword stat_rpt.pwd Dispperf
–d > results.txt
In this example, DispPerf clears its buffer of all profiling information. The Microsoft® Pocket Word application is launched and opens the document Stat_rpt.pwd. DispPerf tracks the profiled display functions called by Pocket Word. Finally, DispPerf writes its table of profiling information to the Results.txt file.