关于vb某效率-.-
basic游戏吧
全部回复
仅看楼主
level 11
space🌚 楼主
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private Sub Form_Load()
    Show
    AutoRedraw = True
    Dim t As Long
    Dim t1 As Long
    Dim t2 As Long
    Dim i As Long
   
    t = timeGetTime
    For i = 1 To 100
        d
        Me.Cls
    Next
    t1 = timeGetTime - t
   
    t = timeGetTime
    For i = 1 To 100
        d
        Me.Line (0, 0)-(Me.ScaleWidth - 1, Me.ScaleHeight - 1), BackColor, BF
    Next
    t2 = timeGetTime - t
   
    Debug.Print t1, t2
    End
End Sub
Private Sub d() '画上东西...模拟实际应用...
    Me.Line (0, 0)-(50, 50), , BF
    Me.Line (50, 50)-(100, 100), , BF
    Me.Line (100, 100)-(150, 150), , BF
    Me.Circle (60, 60), 10
    Me.Circle (60, 80), 10
    Me.Circle (60, 100), 10
End Sub
是line清屏快还是cls清屏快[揉脸]
2010年07月19日 12点07分 1
level 1
BUDONG -.-
2010年07月19日 12点07分 2
level 6
VB这方面我懂得很少很少,恨才疏学浅。帮你顶下,期待高手解答[Yeah][顶]
2010年07月19日 14点07分 3
level 8
按你的试试看不就知道了?我猜想是cls比较快、具体autoredraw实现的原理我不知道、不过我可以知道的是、当autoredraw=true的时候、并不是你画上去的没有被擦出、只是在窗体重绘的绘制、VB自动的再次帮你画上去、而cls我猜想就是就需要重绘的缓冲区给清空了
2010年07月21日 08点07分 4
level 11
space🌚 楼主
回复:4楼
autoredraw=true时line更快,=false时差不多
2010年07月21日 10点07分 5
level 1
试一试不就行了,但在试之前,我猜测:
1.在AutoRedraw情况下
(1)AutoRedraw缓冲区有限,Line次数如果太多可能会溢出;
(2)Cls可以清空缓冲区,释放内存,但是也需要执行一次Line。
2.在不打开的情况下
(1)缓冲区不存在,此时Cls就是执行一次Line,Cls需要跳转到Line继续执行。
召唤器开启!@vb2070 @sunshinebean 都来吧!
2011年08月27日 09点08分 6
level 1
根据测试结果显示,我的猜测对了:
在AutoRedraw = True时:Cls比Line快
在AutoRedraw = False时:Line比Cls快
2011年08月27日 09点08分 7
level 4
[瀑布汗~]
2011年08月27日 14点08分 8
level 4
[顶]
2011年08月28日 10点08分 9
level 9
空格被挖坟了。。
2011年08月29日 05点08分 10
level 4
我测试的结果是:autoredraw值为true或false时,line都更快。
2011年10月21日 13点10分 11
1