QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: SMcNeill on August 08, 2019, 05:41:29 pm

Title: Various Input Speed Comparisons
Post by: SMcNeill on August 08, 2019, 05:41:29 pm
Here's another old program which I stumbled across while cleaning up my drive:

Code: QB64: [Select]
  1. DEFLNG A-Z
  2.  
  3.     a$ = INKEY$
  4.     count = count + 1
  5.     IF timeit = 0 THEN t# = TIMER(0.001) + 5: timeit = -1
  6. LOOP UNTIL timeit AND TIMER(0.001) > t#
  7. LOCATE 1, 1: PRINT count
  8.  
  9. count = 0: timeit = 0
  10.     a = _KEYHIT
  11.     count = count + 1
  12.     IF timeit = 0 THEN t# = TIMER(0.001) + 5: timeit = -1
  13. LOOP UNTIL timeit AND TIMER(0.001) > t#
  14. LOCATE 2, 1: PRINT count
  15.  
  16. count = 0: timeit = 0
  17.     IF _KEYDOWN(65) THEN REM 'lets do nothing but check for that keydown event
  18.     count = count + 1
  19.     IF timeit = 0 THEN t# = TIMER(0.001) + 5: timeit = -1
  20. LOOP UNTIL timeit AND TIMER(0.001) > t#
  21. LOCATE 3, 1: PRINT count
  22.  
  23.     _LIMIT 30

Compile and run it, and give it 15 seconds to do its thing.  When finished, there'll be three numbers on the screen which represent how many times QB64 can process an INKEY$ event, _KEYHIT, and _KEYDOWN, each over 5 seconds.

People sometimes ask me why I always tend to use KEYHIT over the other methods.  I think this should showcase why quite readily.  ;D
Title: Re: Various Input Speed Comparisons
Post by: Petr on August 09, 2019, 05:08:00 am
Thank you, Steve. Very interrest outputs!

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Various Input Speed Comparisons
Post by: TempodiBasic on August 10, 2019, 04:48:27 pm
Yes great tip!

I can confirm the so strong difference among the 3 way to take input from keyboard on my old TOSHIBA  Celeron 1GigaHzh 4Giga RAM windows 10
  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Thanks