10-14-2022, 07:15 PM
(10-14-2022, 05:55 PM)Pete Wrote: Hey guys, banter aside, just don't miss the point of why I made this post in the first place, to call attention to a peculiar slow-down event, caused by assigning a variable to SCREEN().
I'm just not seeing that type of behavior. Something else is causing your slow-down event, but I don't think it's the use of SCREEN being assigned a variable. See this little timed demo below:
Code: (Select All)
Cls , 4
t# = Timer
For i = 1 To 10000000
If Screen(1, 1) Then
If Screen(1, 1) <> Screen(1, 1) Then End
End If
Next
t1# = Timer
For i = 1 To 10000000
h = Screen(1, 1)
If h Then
If h <> h Then End
End If
Next
t2# = Timer
Print Using "###.#### seconds with 3 screen"; t1# - t#
Print Using "###.#### seconds with 3 variables"; t2# - t1#
And the screenshot of my results -- ran first without any c-optimizations, and then a second time by clicking the option to enable c-optimations.
First run was 0.2 seconds vs 0.05 seconds.
Second run was 0.17 seconds vs 0.05 seconds.
In both cases, it was noticeably faster to assign the value of SCREEN to a variable, than it was to make 3 distinct calls to that same SCREEN statement. (OF course, keep in mind that this is also over 10,000,000 iterations, so the overall difference in speed is almost negligible one way or the other.)
There's nothing here, however, that seems to indicate that using SCREEN is faster than using a variable holding the value of SCREEN. You might be seeing a speed difference in your code, but I don't think it's from what you're attributing it to.