这样能不能用来测试CPU的速度。。。。
漫反射 发表于 2011-10-20 18:12
你要怎样测试呢?
来,画个大红心来测试下cpu计算能力
#include <GDIPlus.au3>
#Include <Timers.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Opt('MustDeclareVars', 1)
Global Const $iW = 400
Global Const $iH = 400
Global Const $radius = 200
Global Const $pi = ACos(-1)
Global Const $dy = 30
Global $dist, $p, $l, $r, $col, $Init, $Timer
Global $hWnd = GUICreate("GDI+ Heart Test CPU", $iW, $iH)
GUISetState()
GUISetOnEvent(-3, "_Close")
_GDIPlus_Startup()
Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
Global $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
Global $hPen = _GDIPlus_PenCreate(0, 1)
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)
$Init = _Timer_Init()
Draw()
GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")
$Timer = _Timer_Diff($Init)
MsgBox(0, "绘红心费时", "窗口大小:" & $iW & " × " & $iH & @CRLF & _
"绘心时长:" & $Timer)
Func Draw()
_GDIPlus_GraphicsClear($hBackbuffer)
For $y = 1 To $iH
For $x = 1 To $iW
$dist = Sqrt((($iW / 2) - $x) ^ 2 + (($iH / 2) - $y) ^ 2)
$p = ATan2(($iW / 2) - $x, ($iH / 2) - $y)
$l = Abs($p) / $pi
$r = (13 * $l - 22 * $l ^ 2 + 10 * $l ^ 3) / (6 - 5 * $l) * $radius
If $dist <= $r Then
$col = "FF0000"
Else
$col = "000000"
EndIf
_GDIPlus_PenSetColor($hPen, "0xFF" & $col)
_GDIPlus_GraphicsDrawRect($hBackbuffer, $x, $y - $dy, 1, 1, $hPen)
Next
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iW, $iH)
Next
EndFunc
Func ATan2($y, $x)
Return (2 * ATan($y / ($x + Sqrt($x * $x + $y * $y))))
EndFunc
Func WM_ERASEBKGND()
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iW, $iH)
Return 1
EndFunc
Func _Close()
GUIRegisterMsg($WM_ERASEBKGND, "")
_GDIPlus_PenDispose($hPen)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hBackbuffer)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()
GUIDelete($hWnd)
Exit
EndFunc
|