iseahound

ImagePut #2 - New HBitmap vs Old HBitmap

May 23rd, 2020
1,984
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include ImageEqual.ahk
  2.  
  3. errors := 0
  4. Loop 1000 {
  5. QPC(1)
  6.  
  7. hBitmap := ImagePutHBitmap("xd.png", 0xFFFFFFFF)
  8.  
  9. old += QPC()
  10. if !ImageEqual(hBitmap, "xd.png")
  11.    errors+=1
  12. DllCall("DeleteObject", "ptr", hBitmap)
  13.  
  14. QPC(1)
  15.  
  16. hBitmap := ImagePutHBitmap("xd.png")
  17.  
  18. new += QPC()
  19. if !ImageEqual(hBitmap, "xd.png")
  20.    errors+=1
  21. }
  22. DllCall("DeleteObject", "ptr", hBitmap)
  23.  
  24. if (old > new)
  25.    winner := "New Version wins by " old - new " and is " Abs(old - new)/new*100 "% faster."
  26. else
  27.    winner := "Old Version wins by " new - old " and is " Abs(old - new)/old*100 "% faster."
  28.  
  29. MsgBox % "Old Version:`t" old "`nNew Version:`t" new "`n" winner
  30. MsgBox % "Number of errors:`t" errors
  31. return
  32.  
  33. Esc:: ExitApp
  34.  
  35. QPC( R := 0 ) {    ; By SKAN,  http://goo.gl/nf7O4G,  CD:01/Sep/2014 | MD:01/Sep/2014
  36.   Static P := 0,  F := 0,     Q := DllCall( "QueryPerformanceFrequency", "Int64P",F )
  37. Return ! DllCall( "QueryPerformanceCounter","Int64P",Q ) + ( R ? (P:=Q)/F : (Q-P)/F )
  38. }
RAW Paste Data