AutoIT Speed Tester


SUBMITTED BY: Guest

DATE: May 29, 2013, 7:09 a.m.

FORMAT: Text only

SIZE: 4.4 kB

HITS: 2052

  1. ; AUTOIT SPEED TESTER
  2. ; What is faster in autoIT3?
  3. ; ????????????????????????????????????????????????????????????????????????????
  4. ; What I know for sure as of version 3.2.4.9:
  5. ;
  6. ; 1. For/next loops are champions. Try not to use While/Wend or Do/Until
  7. ; 2. If $Val is faster than If $Val = 1 or $Val = TRUE.
  8. ; 3. If $Val = 1 is faster than $Val = TRUE
  9. ; 4. If Not $Val is faster than If $Val = 0 or $Val = FALSE.
  10. ; 5. If $Val = 0 is faster than If $Val = FALSE
  11. ; 6. < and > are faster than =, >= or >= (Wow!)
  12. ; 7. $i += 1 is faster than $i = $i + 1
  13. ; 8. If doing a lot of verifications on a single variable:
  14. ; Switch is fastest, Select is second (but slow) and If is slowest.
  15. ; 9. If $Val is a string, If Not $Val is faster than If $Val = ""
  16. ; If $Val is faster than If $Val <> ""
  17. ; 10. When doing binary operations, If $Val -128 > 0 is twice as fast
  18. ; as If BitAnd($Val, 128).
  19. ;
  20. ; IMPORTANT: To get precise timings, TURN OFF ALL RUNNING PROGRAMS!
  21. ; To get compiled speeds ... compile and run :) (that was easy)
  22. ; Also note different CPU/Chipset/GPUs can affect results.
  23. ; It's been brought to my attention by chris95219 that GetTickCount() cannot be properly timed
  24. ; Also if you modify $i and $j (both loop counters) you will obviously get incorrect results!
  25. ; Other functions that can't be tested ... Exit (!) and Return (for obvious reasons)
  26. ; ????????????????????????????????????????????????????????????????????????????
  27. Global $Chrono[21] ; Chronometer values
  28. Global $Mess = "Timer values"&@CR ; String to contain MsgBox content.
  29. ; Declare all necessary variables for your test code here
  30. $Val = 0
  31. ; Actual timing loops
  32. ; ============================================================================
  33. For $i = 1 To 20 ; 20 iterations of set
  34. $go = TimerInit() ; Start your engines!
  35. For $j = 1 To 9999 ; 9999 iterations of commands here
  36. ; For complex test code, reduce value
  37. ; although I suggest to test small bits instead.
  38. ; Insert your test code here
  39. ; Remove all commands to get a base reading (when you substract the base
  40. ; value from the values you get when you add a command, you will get the
  41. ; true time it took to process your command.
  42. ; IMPORTANT: Then ConsoleWrite("") serves as a dummy opreation to satisfy
  43. ; the IF condition.
  44. If $Val Then ConsoleWrite("")
  45. Next ; $j
  46. $Chrono[$i] = TimerDiff($go) ; Ok, how long did it take?
  47. $Mess &= "Pass "&$i&" = "&$Chrono[$i]&"ms"&@CR ; Jolt it down for the report
  48. Next ; $i
  49. ; ============================================================================
  50. _Report() ; ... err report it!
  51. Exit
  52. ; ==== FUNCTIONS =============================================================
  53. Func _Report()
  54. $Mess &= @CR ; Add an empty line
  55. $Mess &= "Min: "&_Minn()&"ms"&@CR ; Find minimum value and add it
  56. $Mess &= "Max: "&_Maxx()&"ms"&@CR ; Find maximum value and add it
  57. $Mess &= "Ave: "&_Ave()&"ms"&@CR ; Calculate median value and add it!
  58. MsgBox(48,"Results",$Mess) ; Show it to the user --> see how @CR works?
  59. EndFunc
  60. Func _Maxx() ; Find maximum value and return it
  61. Local $i, $Max ; Set local variables
  62. For $i = 1 To Ubound($Chrono) -1 ; Read all values in $Chrono, from 1 to end
  63. If $Chrono[$i] > $Max Then $Max = $Chrono[$i] ; If the current value is larger than the current max, it is the new max.
  64. Next
  65. Return $Max ; Send back the value
  66. EndFunc
  67. Func _Minn() ; Find minimum value and add it
  68. Local $i, $Min = $Chrono[1] ; Set local variables. Notice $Min which equals the first value in $Chrono
  69. For $i = 1 To Ubound($Chrono) -1 ; Read all values in $Chrono, from 1 to end
  70. If $Chrono[$i] < $Min Then $Min = $Chrono[$i] ; If the current value is lower than the current min, it is the new min.
  71. Next
  72. Return $Min ; Send back the value
  73. EndFunc
  74. Func _Ave() ; Find average value and return it
  75. Local $i, $Ave ; Set local variables
  76. For $i = 1 To Ubound($Chrono) -1 ; Read all values in $Chrono, from 1 to end
  77. $Ave += $Chrono[$i] ; Add up all the values
  78. Next
  79. Return $Ave / $i ; Send back the value, dividing total by # of numbers added together --> average
  80. EndFunc

comments powered by Disqus