Checks maximum speed that can be obtained by reading from the LPT port.
5,000,000 bytes are read into a buffer in a loop as fast as possible.
Time elapsed and obtained speed of sampling are reported.
Requires port95nt.exe (DLPORTIO) on Windows 32 bit, see here for 64 bit.
Run it multipe time to get an impression of the accuracy that can be obtained, with the rest of Windows interfering. The code contains thread and process priority raised to as high levels as possible, the influence of this is minor but visible.
Test results so far:
– Pentium IV notebook Windows 98 Se 650 kHz (648-652)
– Gateway 7 (Pentium III 450) 680 kHz (678-681)
– DELL Optiplex Dual Core 5400 2.3 GHz 720 kHz (719-721)
It seems that the parallel port architecture + DLPORTIO limits the speed of sampling.
Program + source of LPT Speed (Delphi 7).
The procedure doing the sampling is shown here. Note that the port has to be set to input, see the parallel port page for information on that.
procedure TLPTSpeed.bcaptureClick(Sender: TObject); var start,stop, freq:int64; elapsed : extended ; buffercount :cardinal ; begin QueryPerformanceFrequency(freq); {Get frequency} buffercount := 1 ; screen.cursor:=crHourGlass; {show busy cursor} {collect data } SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS ); SetThreadPriority( GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL ); QueryPerformanceCounter(start); {Get initial count} repeat buffer[buffercount] := DlPortReadPortUchar($378) ; buffercount := buffercount + 1 ; until buffercount = bufferlen ; QueryPerformanceCounter(stop); SetPriorityClass( GetCurrentProcess, NORMAL_PRIORITY_CLASS ); SetThreadPriority( GetCurrentThread, THREAD_PRIORITY_NORMAL ); screen.cursor:=crDefault; {show normal cursor} { report } elapsed := ((stop - start) * 1000) / freq ; log.lines.add(FormatFloat('0.00',(elapsed))+ ' ms') ; elapsed := bufferlen / (elapsed) ; log.lines.add('Frequency = ' + FormatFloat('0.00',elapsed) + 'kHz') ; end;