漫反射 发表于 2011-10-20 18:12:07

用AU3写个几百万的循环运算能用来测试电脑CPU的性能吗?

这样能不能用来测试CPU的速度。。。。

魔导 发表于 2011-10-23 18:09:21

U够用就行了 就像你的车一样
时速10000   100 1000没多打区别的
楼主要看性能的话建议鲁大师

netegg 发表于 2011-10-23 22:32:09

戏不大,auto没法真正实现浮点运算

happytc 发表于 2011-10-24 10:42:34

这样能不能用来测试CPU的速度。。。。
漫反射 发表于 2011-10-20 18:12 http://www.autoitx.com/images/common/back.gif

你要怎样测试呢?
来,画个大红心来测试下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

YUJIE 发表于 2011-10-30 14:37:49

回复 4# happytc
楼主 这个脚本写的很NB
页: [1]
查看完整版本: 用AU3写个几百万的循环运算能用来测试电脑CPU的性能吗?