Author Topic: Various Input Speed Comparisons  (Read 2589 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Various Input Speed Comparisons
« 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
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Various Input Speed Comparisons
« Reply #1 on: August 09, 2019, 05:08:00 am »
Thank you, Steve. Very interrest outputs!

  [ You are not allowed to view this attachment ]  

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Various Input Speed Comparisons
« Reply #2 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
  [ You are not allowed to view this attachment ]  

Thanks
Programming isn't difficult, only it's  consuming time and coffee