/
keycal.4th
55 lines (48 loc) · 1.21 KB
/
keycal.4th
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
\ keycal.4th
\
\ Measure keyboard event response time for your system.
\
\ This program measures the average time between the press of a
\ key and when it is processed by the system. There will be
\ a significant non-zero delay due to processor interrupts,
\ thread priorities, and other operating system factors.
\
\ Copyright (c) 2003 Krishna Myneni
\ Provided under the GNU General Public License
\
\ Revisions:
\
\ 2003-3-2 created km
\
500 constant MAXWAIT \ maximum response time in milliseconds
variable niter
variable keepwaiting
variable kbresp
: cal
begin key? until key drop \ wait for key press
0 niter !
true keepwaiting !
0
begin
ms@
begin key? 0= keepwaiting @ and
while ms@ over - MAXWAIT > if false keepwaiting ! then
repeat
keepwaiting @
while
key drop ms@ swap - +
1 niter +!
repeat
drop cr
niter @ dup if / dup kbresp !
." Average keyboard response time was " . ." ms" cr
." Number of events = " niter @ . cr
else
2drop ." No data" cr
then
;
cr cr
.( Hold down the spacebar for about 30 seconds and release it ) cr
.( to calibrate the average interruption time for reading a ) cr
.( keyboard event on your system. Type 'cal' to repeat. ) cr cr
cal