Code: Select all
SetBatchLines -1
f := 10000, a := b := c := d := 0
MsgBox Ready?
size := 256
DllCall("QueryPerformanceFrequency", "int64*", frequency:=0)
loop % f {
; ((Test 1))
DllCall("QueryPerformanceCounter", "int64*", start:=0)
hMap := DllCall("CreateFileMapping", "Ptr", -1, "Ptr", 0, "uInt", 0x04, "uInt", 0, "uInt", size, "Ptr", 0, "Ptr")
pMap := DllCall("MapViewOfFile", "Ptr", hMap, "uInt", 0x2, "uInt", 0, "uInt", 0, "uPtr", 0, "Ptr")
NumPut(9777, pMap+0, "uint")
DllCall("QueryPerformanceCounter", "int64*", end:=0)
NumGet(pMap+0, "uint")
DllCall("UnmapViewOfFile", "Ptr", pMap)
DllCall("CloseHandle", "Ptr", hMap)
a += end - start
; ((Test 2))
DllCall("QueryPerformanceCounter", "int64*", start:=0)
ptr := DllCall("GlobalAlloc", "uint", 0, "uptr", size, "ptr")
NumPut(9777, ptr+0, "uint")
DllCall("QueryPerformanceCounter", "int64*", end:=0)
NumGet(ptr+0, "uint")
DllCall("GlobalFree", "ptr", ptr)
b += end - start
; ((Test 3))
ProcessHeap := DllCall("GetProcessHeap")
DllCall("QueryPerformanceCounter", "int64*", start:=0)
ptr := DllCall("HeapAlloc", "uint", ProcessHeap, "uint", 0, "uint", size)
NumPut(9777, ptr+0, "uint")
DllCall("QueryPerformanceCounter", "int64*", end:=0)
NumGet(ptr+0, "uint")
DllCall("HeapFree", "ptr", ProcessHeap, "uint", HeapFree, "ptr", ptr)
c += end - start
; ((Test 4))
DllCall("QueryPerformanceCounter", "int64*", start:=0)
ptr := DllCall("Ole32\CoTaskMemAlloc", "uint", size)
NumPut(9777, ptr+0, "uint")
DllCall("QueryPerformanceCounter", "int64*", end:=0)
NumGet(ptr+0, "uint")
DllCall("Ole32\CoTaskMemFree", "ptr", ptr)
d += end - start
}
a := a / frequency
a := f / a
b := b / frequency
b := f / b
c := c / frequency
c := f / c
d := d / frequency
d := f / d
MsgBox % "File Mapping:`t" Round(a, 2) " fps"
. "`n" "GlobalAlloc:`t" Round(b, 2) " fps"
. "`n" "HeapAlloc:`t" Round(c, 2) " fps"
. "`n" "CoTaskMemAlloc:`t" Round(d, 2) " fps"