[Testers Needed] Please give me feedback on which method is the fastest

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: [Testers Needed] Please give me feedback on which method is the fastest

16 Jun 2017, 05:06

Since I dont know c++, I'm not sure if this is correct ^^

Code: Select all

int IsBetween( int num, int low, int high, int loops )
{
    int found = 0;
    int diff = ( high - low ) + 1;

    for( int i = 1; i <= loops; i++ )
        if ( ( num - low ) < diff )
            found++;

    return found;
}
The return with 2073600 is correct, so it loops really 2073600 times

Code: Select all

#NoEnv
SetBatchLines -1

global number_lower := 50
global number_upper := 100
global number_magic := 66
global number_found := true

; ==================================================================

number_diff := (number_upper - number_lower) + 1

QPC(True)

loop 2073600
    if ((number_magic - number_lower) < number_diff)
        number_found := true

Timer1 := QPC(False)

; ==================================================================

QPC(True)

loop 2073600
    if (number_magic >= number_lower) && (number_magic <= number_upper)
        number_found := true

Timer2 := QPC(False)

; ==================================================================

QPC(True)

loop 2073600
    if ((number_magic - number_lower) <= (number_upper - number_lower))
        number_found := true

Timer3 := QPC(False)

; ==================================================================

MyFunction := MCode("2,x64:QSnQRYXJfhgp0bgAAAAAQTnIQQ9NwcNmDx+EAAAAAAAxwMOQkJCQkJCQkJCQkJCQ")

QPC(True)

ret := DllCall(MyFunction, "int", number_magic, "int", number_lower, "int", number_upper, "int", 2073600, "cdecl")

Timer4 := QPC(False)

; ==================================================================

MsgBox % Timer1 "`n" Timer2 "`n" Timer3 "`n" Timer4 " (" ret ")"

; ==================================================================

QPC(R := 0)
{
    static P := 0, F := 0, Q := DllCall("QueryPerformanceFrequency", "Int64P", F)
    return ! DllCall("QueryPerformanceCounter", "Int64P", Q) + (R ? (P := Q) / F : (Q - P) / F) 
}

MCode(mcode)
{
    static e := {1:4, 2:1}, c := (A_PtrSize = 8) ? "x64" : "x86"
    if (!regexmatch(mcode, "^([0-9]+),(" c ":|.*?," c ":)([^,]+)", m))
        return
    if (!DllCall("crypt32\CryptStringToBinary", "str", m3, "uint", 0, "uint", e[m1], "ptr", 0, "uint*", s, "ptr", 0, "ptr", 0))
        return
    p := DllCall("GlobalAlloc", "uint", 0, "ptr", s, "ptr")
    if (c="x64")
        DllCall("VirtualProtect", "ptr", p, "ptr", s, "uint", 0x40, "uint*", op)
    if (DllCall("crypt32\CryptStringToBinary", "str", m3, "uint", 0, "uint", e[m1], "ptr", p, "uint*", s, "ptr", 0, "ptr", 0))
        return p
    DllCall("GlobalFree", "ptr", p)
}

Code: Select all

0.324321
0.432744
0.369919
0.000006    ; mcode
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [Testers Needed] Please give me feedback on which method is the fastest

16 Jun 2017, 05:24

Try to compile it without any opimasation flags jNizM
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: [Testers Needed] Please give me feedback on which method is the fastest

16 Jun 2017, 05:26

MyFunction := MCode("2,x64:VUiJ5UiD7BCJTRCJVRhEiUUgRIlNKMdF/AAAAACLRSArRRiDwAGJRfTHRfgBAAAAi0X4O0UofxWLRRArRRg5RfR+BINF/AGDRfgB6+OLRfxIg8QQXcOQkJCQkJCQkJCQ")

Code: Select all

0.310448
0.398040
0.351051
0.004427 (mcode)
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [Testers Needed] Please give me feedback on which method is the fastest

16 Jun 2017, 05:36

Your first code was probably optimised to do one check and either return 0 or loops.
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: [Testers Needed] Please give me feedback on which method is the fastest

16 Jun 2017, 06:41

It looks like (repeatedly) setting the variable to true about doubles the time execution takes. Would breaking out of the loop be beneficial?

Code: Select all

First check method:
If number 88 is between 50-100 is true and it took 0.517209
Second check method:
If number 88 is between 50-100 is true and it took 0.851986

First check method:
If number 50 is between 50-100 is true and it took 0.526072
Second check method:
If number 50 is between 50-100 is true and it took 0.852744

First check method:
If number monkey is between 50-100 is true and it took 0.518197
Second check method:
If number monkey is between 50-100 is true and it took 0.634747


First check method:
If number 166 is between 50-100 is false and it took 0.284502
Second check method:
If number 166 is between 50-100 is false and it took 0.586217

First check method:
If number -53 is between 50-100 is false and it took 0.292423
Second check method:
If number -53 is between 50-100 is false and it took 0.304194
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: [Testers Needed] Please give me feedback on which method is the fastest

16 Jun 2017, 06:44

Nice tests :) happy to see all the results

but for the math to work the first value needs to be unsigned or else you will not get the correct result when testing with values that are NOT between the high and low end

Code: Select all

#NoEnv
SetBatchLines -1

global number_lower := 50
global number_upper := 100
global number_found := 0
global number_found2 := 0

; ==================================================================

global number_magic := 66

number_diff := (number_upper - number_lower) + 1

loop 2073600
    if ((number_magic - number_lower) < number_diff)
        number_found := true

Timer1 := QPC(False)

; ==================================================================

global number_magic := 33

number_diff := (number_upper - number_lower) + 1

loop 2073600
    if ((number_magic - number_lower) < number_diff)
        number_found2 := true

msgbox % "1:" number_found "`n2:" number_found2
the over all idea is still a pre test to see if this comparison really seems faster before trying it with the Autohotkey pixel/image search code as i believe that those functions does that comparison so many times that something as simple as making the if quicker can give a useful speed boost with very little source editing

@Nextron well it will not simply set the variable :) but sure if it was simply a test to make the loop faster, then sure :)
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: [Testers Needed] Please give me feedback on which method is the fastest

16 Jun 2017, 07:53

The unsinged conversion needs to much time.. without the results are wrong

Tested with 4K (3840x2160)

Code: Select all

#NoEnv
SetBatchLines -1

global number_min    := 1
global number_lower  := 2073600
global number_upper  := 6220800
global number_max    := 8294400        ; 4K

global number_loops  := 3840 * 2160    ; 4K

global number_found1 := 0
global number_found2 := 0
global number_found3 := 0

; ==================================================================

QPC(True)

number_diff := (number_upper - number_lower) + 1

loop % number_loops
    if (((A_Index - number_lower) & 0xFFFFFFFF) < number_diff)
        number_found1++

Timer1 := QPC(False)

; ==================================================================

QPC(True)

loop % number_loops
    if (A_Index >= number_lower) && (A_Index <= number_upper)
        number_found2++

Timer2 := QPC(False)

; ==================================================================

MyFunction := MCode("2,x64:VUiJ5UiD7BCJTRCJVRhEiUUgx0X8AAAAAItFGCtFEIPAAYlF9MdF+AEAAACLRfg7RSB/FYtF+CtFEDlF9HYEg0X8AYNF+AHr44tF/EiDxBBdw5CQkJCQkJCQkJCQkJCQ")

QPC(True)

number_found3 := DllCall(MyFunction, "uint", number_lower, "uint", number_upper, "int", number_loops, "cdecl")

Timer3 := QPC(False)

; ==================================================================

MsgBox % "Timer 1:`n" Timer1 " (" number_found1 ")`n`nTimer 2:`n" Timer2 " (" number_found2 ")`n`nTimer 3:`n" Timer3 " (" number_found3 ")"

; ==================================================================

QPC(R := 0)
{
    static P := 0, F := 0, Q := DllCall("QueryPerformanceFrequency", "int64*", F)
    return !DllCall("QueryPerformanceCounter", "int64*", Q) + (R ? (P := Q) / F : (Q - P) / F) 
}

MCode(mcode)
{
    static e := {1:4, 2:1}, c := (A_PtrSize = 8) ? "x64" : "x86"
    if (!regexmatch(mcode, "^([0-9]+),(" c ":|.*?," c ":)([^,]+)", m))
        return
    if (!DllCall("crypt32\CryptStringToBinary", "str", m3, "uint", 0, "uint", e[m1], "ptr", 0, "uint*", s, "ptr", 0, "ptr", 0))
        return
    p := DllCall("GlobalAlloc", "uint", 0, "ptr", s, "ptr")
    if (c="x64")
        DllCall("VirtualProtect", "ptr", p, "ptr", s, "uint", 0x40, "uint*", op)
    if (DllCall("crypt32\CryptStringToBinary", "str", m3, "uint", 0, "uint", e[m1], "ptr", p, "uint*", s, "ptr", 0, "ptr", 0))
        return p
    DllCall("GlobalFree", "ptr", p)
}

Code: Select all

Timer 1:
1.209854 (4147201)

Timer 2:
1.105824 (4147201)

Timer 3:
0.014799 (4147201)

Code: Select all

int IsBetween(unsigned int low, unsigned int high, int loops)
{
    int found = 0;
    unsigned int diff = (high - low) + 1;

    for(int i = 1; i <= loops; i++)
        if ((unsigned)(i - low) < diff)
            found++;

    return found;
}
Not sure if cpp is correct =)
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [Testers Needed] Please give me feedback on which method is the fastest

16 Jun 2017, 08:35

@Blackholyman, if you have the numbers on the unsigned form from the beginning the gain is from skipping the && number <= upper, the acutal Y<Q is not quicker than number <= upper, if you cannot put the number on the unsigned form quicker than && number <= upper, forget about it.

Also in the context of the code you posted here, I would start optimising anything but the compairson. ;)
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: [Testers Needed] Please give me feedback on which method is the fastest

16 Jun 2017, 17:17

Code: Select all

First check method: If number 10 is between 50-100 is false and it took 0.199950
Second check method: If number 10 is between 50-100 is false and it took 0.213425

First check method: If number 25 is between 50-100 is false and it took 0.198929
Second check method: If number 25 is between 50-100 is false and it took 0.216661

First check method: If number 50 is between 50-100 is true and it took 0.352228
Second check method: If number 50 is between 50-100 is true and it took 0.569190

First check method: If number 75 is between 50-100 is true and it took 0.363864
Second check method: If number 75 is between 50-100 is true and it took 0.590481

First check method: If number 100 is between 50-100 is true and it took 0.360400
Second check method: If number 100 is between 50-100 is true and it took 0.564775

First check method: If number 125 is between 50-100 is false and it took 0.198150
Second check method: If number 125 is between 50-100 is false and it took 0.413822

First check method: If number 125 is between 50-100 is false and it took 0.198150
Second check method: If number 125 is between 50-100 is false and it took 0.413822

First check method: If number 300 is between 50-100 is false and it took 0.199598
Second check method: If number 300 is between 50-100 is false and it took 0.404941

First check method: If number 9000 is between 50-100 is false and it took 0.199296
Second check method: If number 9000 is between 50-100 is false and it took 0.412205
I used the code as seen in first post at time of posting this one. Second method seems to be worse everytime.
Last edited by SirRFI on 16 Jun 2017, 17:54, edited 1 time in total.
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [Testers Needed] Please give me feedback on which method is the fastest

16 Jun 2017, 17:35

Code: Select all

First check method:
If number 200 is between 50-100 is true and it took 0.488592

Second check method:
If number 200 is between 50-100 is false and it took 0.475797
:crazy: The test now seems broken for number > upper. There was an example earlier where 200 gave the correct result.
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: [Testers Needed] Please give me feedback on which method is the fastest

19 Jun 2017, 02:19

thanks for all the info...

i just tried the code from my OP and it still seems to work just fine

Code: Select all

First check method:  If number 200 is between 50-100 is false and it took 0.284955
Second check method: If number 200 is between 50-100 is false and it took 0.506049

First check method:  If number 77 is between 50-100 is true and it took 0.514196
Second check method: If number 77 is between 50-100 is true and it took 0.767994

First check method:  If number 44 is between 50-100 is false and it took 0.281468
Second check method: If number 44 is between 50-100 is false and it took 0.274572
@Helgef what test example did you test?

Note: I had made a typo in my OP where the check for building the text string for the msgbox's second methods "true/false" text was done on the variable that was set by the first method as pointed out by evilC here: https://autohotkey.com/boards/viewtopic ... 39#p153839
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [Testers Needed] Please give me feedback on which method is the fastest

19 Jun 2017, 03:07

I ran the code in your first post. Copy-paste, result,

Code: Select all

First check method:
If number 200 is between 50-100 is true and it took 0.486039

Second check method:
If number 200 is between 50-100 is false and it took 0.480104
It seems to work on AHK 32bit though, I run 64 bit by default.

Cheers.
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: [Testers Needed] Please give me feedback on which method is the fastest

19 Jun 2017, 03:29

well the method of making the value unsigned is an old one i copied...

maybe if you replace Y := NumGet( NumPut( Y, Var:="ABCD" )-4, 0,"UInt" ) with Y := Format("{1:u}", Y) it will work for both 32b and 64b (it does for 32b), I don't have access to 64b here so can't test right now
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Testers Needed] Please give me feedback on which method is the fastest

19 Jun 2017, 04:06

Y := NumGet( NumPut( Y, Var:="ABCD" )-4, 0,"UInt" ) should be

Code: Select all

Y := NumGet( NumPut( Y, Var:="ABCD", "Int" )-4, 0,"UInt" )
; or
Y := NumGet( NumPut( Y, Var:="ABCD" )-A_PtrSize, 0,"UInt" )
to work on 64-bit.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: [Testers Needed] Please give me feedback on which method is the fastest

19 Jun 2017, 04:14

Should this not work too (not tested with 32-Bit)? Y := Y & 0xFFFFFFFF (see my example https://autohotkey.com/boards/viewtopic ... 57#p154257)
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Testers Needed] Please give me feedback on which method is the fastest

19 Jun 2017, 05:53

@jNizM:
Of course!

@Blackholyman:
After some testing I think your benchmark approach is wrong. In a real application number would get a new value for each comparison. So the calculation of Y should be part of the first loop.
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: [Testers Needed] Please give me feedback on which method is the fastest

19 Jun 2017, 07:00

Yes that may be true.

AHK source code:

Code: Select all

		BYTE red, green, blue;
		BYTE search_red, search_green, search_blue;
		BYTE red_low, green_low, blue_low, red_high, green_high, blue_high;

		// The following loop is very similar to its counterpart above that finds an exact match, so maintain
		// them together and see above for more detailed comments about it.
		for (i = 0; i < screen_pixel_count; ++i)
		{
			// The following is commented out to trade code size reduction for performance (see comment above).
			//red = GetBValue(screen_pixel[i]);   // Because it's RGB vs. BGR, the B value is fetched, not R (though it doesn't matter as long as everything is internally consistent here).
			//green = GetGValue(screen_pixel[i]);
			//blue = GetRValue(screen_pixel[i]);
			//if ((red >= red_low1 && red <= red_high1
			//	&& green >= green_low1 && green <= green_high1
			//	&& blue >= blue_low1 && blue <= blue_high1 // All three color components are a match, so this screen pixel matches the image's first pixel.
			//		|| image_mask && image_mask[0]         // Or: It's an icon's transparent pixel, which matches any color.
			//		|| image_pixel[0] == trans_color)      // This should be okay even if trans_color==CLR_NONE, since CLR none should never occur naturally in the image.
			//	&& image_height <= screen_height - i/screen_width // Image is short enough to fit in the remaining rows of the search region.
			//	&& image_width <= screen_width - i%screen_width)  // Image is narrow enough not to exceed the right-side boundary of the search region.
			
			// Instead of the above, only this abbreviated check is done:
			if (image_height <= screen_height - i/screen_width    // Image is short enough to fit in the remaining rows of the search region.
				&& image_width <= screen_width - i%screen_width)  // Image is narrow enough not to exceed the right-side boundary of the search region.
			{
				// Since the first pixel is a match, check the other pixels.
				for (found = true, x = 0, y = 0, j = 0, k = i; j < image_pixel_count; ++j)
				{
   					search_red = GetBValue(image_pixel[j]);
	   				search_green = GetGValue(image_pixel[j]);
		   			search_blue = GetRValue(image_pixel[j]);
					SET_COLOR_RANGE
   					red = GetBValue(screen_pixel[k]);
	   				green = GetGValue(screen_pixel[k]);
		   			blue = GetRValue(screen_pixel[k]);

					if (!(found = red >= red_low && red <= red_high
						&& green >= green_low && green <= green_high
                        && blue >= blue_low && blue <= blue_high
							|| image_mask && image_mask[j]     // Or: It's an icon's transparent pixel, which matches any color.
							|| image_pixel[j] == trans_color)) // This should be okay even if trans_color==CLR_NONE, since CLR_NONE should never occur naturally in the image.
						break; // At least one pixel doesn't match, so this candidate is discarded.
					if (++x < image_width) // We're still within the same row of the image, so just move on to the next screen pixel.
						++k;
					else // We're starting a new row of the image.
					{
						x = 0; // Return to the leftmost column of the image.
						++y;   // Move one row downward in the image.
						k = i + y*screen_width; // Verified correct.
					}
				}
				if (found) // Complete match found.
					break;
			}
		}
I was not really trying to test autohotkey's ability in this benchmark more trying to benchmark the 2 if comparisons in the hope that this

Code: Select all

if (!(found = red >= red_low && red <= red_high
	&& green >= green_low && green <= green_high
	&& blue >= blue_low && blue <= blue_high
could be reduced to something like this

Code: Select all

if (!(found = ((unsigned)(red) < red_diff)
	&& ((unsigned)(Green) < Green_diff)
	&& ((unsigned)(Blue) < Blue_diff)
but do see that a more correct way maybe this

Code: Select all

if (!(found = ((unsigned)(red - red_low) < red_diff)
	&& ((unsigned)(Green - Green_low) < Green_diff)
	&& ((unsigned)(Blue - Blue_low) < Blue_diff)
the issue with testing that in AHK code is that any of the methods ("I knew at the time") to make the value of red - red_low unsigned also takes the added time of doing the function call, in the OP code i was hoping to cut that function time out of the benchmark result but do see that this was most likely wrong.

my hope was/is that in c++ (unsigned) is simply a flag, so takes close to no time, where as in ahk it takes some time to do the convert to unsigned

2 examples:
OP code with the math within the timer

Code: Select all

#Persistent
#SingleInstance force
SetBatchLines, -1

f1:: ; speed testing fastest way to determine if an integer is between two integers (inclusive)
time1:=time2:=inrange:=inrange2:="" ; clear variables

lower := 50
upper := 100

InputBox, number, time test, Please Enter a number `n`ni.e 88

diff := (upper-lower)+1

QPX( True ) ; Initialise Counter

loop 2073600 ; loop 1920x1080 times
   if (((number-lower) & 0xFFFFFFFF) < diff)
      inrange := true

time1 := QPX( false ) ; Retrieve Time consumed ( & reset internal vars )

QPX( True ) ; Initialise Counter

loop 2073600 ; loop 1920x1080 times
   if (number >= lower && number <= upper)
      inrange2 := true

time2 := QPX( false ) ; Retrieve Time consumed ( & reset internal vars )

msgbox % "First check method:`nIf number " number " is between " lower "-" upper " is " (inrange?"true":"false") " and it took " time1 "`n`nSecond check method:`nIf number " number " is between " lower "-" upper " is " (inrange2?"true":"false") " and it took " time2
return

QPX( N=0 ) { ; Wrapper for QueryPerformanceCounter()by SKAN | CD: 06/Dec/2009
	Static F,A,Q,P,X ; www.autohotkey.com/forum/viewtopic.php?t=52083 | LM: 10/Dec/2009
	If	( N && !P )
		Return	DllCall("QueryPerformanceFrequency",Int64P,F) + (X:=A:=0) + DllCall("QueryPerformanceCounter",Int64P,P)
	DllCall("QueryPerformanceCounter",Int64P,Q), A:=A+Q-P, P:=Q, X:=X+1
	Return	( N && X=N ) ? (X:=X-1)<<64 : ( N=0 && (R:=A/X/F) ) ? ( R + (A:=P:=X:=0) ) : 1
}

Code: Select all

First check method:  If number 44 is between 50-100 is false and it took 0.568369
Second check method: If number 44 is between 50-100 is false and it took 0.277781

First check method:  If number 88 is between 50-100 is true and it took 0.763220
Second check method: If number 88 is between 50-100 is true and it took 0.757578

First check method:  If number 222 is between 50-100 is false and it took 0.589628
Second check method: If number 222 is between 50-100 is false and it took 0.511960
more like what i think is happening in the c++ code

Code: Select all

#Persistent
#SingleInstance force
SetBatchLines, -1

f1:: ; speed testing fastest way to determine if an integer is between two integers (inclusive)
time1:=time2:=inrange:=inrange2:="" ; clear variables

lower := 50
upper := 100

InputBox, number, time test, Please Enter a number `n`ni.e 88

diff := (upper-lower)+1

QPX( True ) ; Initialise Counter

loop 20736 ; loop 1920x1080 times  / 100
{
	Y := ((number-lower) & 0xFFFFFFFF)
	loop 100
		if (Y < diff)
			inrange := true
  }

time1 := QPX( false ) ; Retrieve Time consumed ( & reset internal vars )

QPX( True ) ; Initialise Counter

loop 20736 ; loop 1920x1080 times / 100
	loop 100
		if (number >= lower && number <= upper)
			inrange2 := true

time2 := QPX( false ) ; Retrieve Time consumed ( & reset internal vars )

msgbox % "First check method:`nIf number " number " is between " lower "-" upper " is " (inrange?"true":"false") " and it took " time1 "`n`nSecond check method:`nIf number " number " is between " lower "-" upper " is " (inrange2?"true":"false") " and it took " time2
return

QPX( N=0 ) { ; Wrapper for QueryPerformanceCounter()by SKAN | CD: 06/Dec/2009
	Static F,A,Q,P,X ; www.autohotkey.com/forum/viewtopic.php?t=52083 | LM: 10/Dec/2009
	If	( N && !P )
		Return	DllCall("QueryPerformanceFrequency",Int64P,F) + (X:=A:=0) + DllCall("QueryPerformanceCounter",Int64P,P)
	DllCall("QueryPerformanceCounter",Int64P,Q), A:=A+Q-P, P:=Q, X:=X+1
	Return	( N && X=N ) ? (X:=X-1)<<64 : ( N=0 && (R:=A/X/F) ) ? ( R + (A:=P:=X:=0) ) : 1
}

Code: Select all

First check method:  If number 44 is between 50-100 is false and it took 0.292560
Second check method: If number 44 is between 50-100 is false and it took 0.292357

First check method:  If number 88 is between 50-100 is true and it took 0.534627
Second check method: If number 88 is between 50-100 is true and it took 0.773438

First check method:  If number 222 is between 50-100 is false and it took 0.288689
Second check method: If number 222 is between 50-100 is false and it took 0.521938
to me that last example mimics the pixel/image search code better as it is checking the same image pixel ageist many screen pixels
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: haomingchen1998, ReyAHK and 233 guests