Code: [Select all] [Download] GeSHi © Codebox Plus

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] [Expand] [Download] GeSHi © Codebox Plus

#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] [Download] GeSHi © Codebox Plus

0.324321

0.432744

0.369919

0.000006 ; mcode