sashar2 писал(а):Dim T&, I&
Вот эта строка не понятна, что означает & после переменной?
В точности то же, что As Long
While / Wend - в точности то же, что Do While / Loop. Про циклы Do знаешь?
sashar2 писал(а):Dim T&, I&
Вот эта строка не понятна, что означает & после переменной?
Больше нет предложений с еще более "быстрым кодом" ? =)
mov eax, 0
start: inc eax
jmp start
Option Explicit
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private Declare Function GetTickCount& Lib "kernel32" ()
Private Type LARGE_INTEGER
LowPart As Long
HighPart As Long
End Type
Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As LARGE_INTEGER) As Long
Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As LARGE_INTEGER) As Long
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Dim liFrequency As LARGE_INTEGER
Dim cuFrequency As Currency, cuStart As Currency, cuStop As Currency
Dim T As Long, liStart As LARGE_INTEGER, liStop As LARGE_INTEGER
Const THREAD_BASE_PRIORITY_IDLE = -15
Const THREAD_BASE_PRIORITY_LOWRT = 15
Const THREAD_BASE_PRIORITY_MIN = -2
Const THREAD_BASE_PRIORITY_MAX = 2
Const THREAD_PRIORITY_LOWEST = THREAD_BASE_PRIORITY_MIN
Const THREAD_PRIORITY_HIGHEST = THREAD_BASE_PRIORITY_MAX
Const THREAD_PRIORITY_BELOW_NORMAL = (THREAD_PRIORITY_LOWEST + 1)
Const THREAD_PRIORITY_ABOVE_NORMAL = (THREAD_PRIORITY_HIGHEST - 1)
Const THREAD_PRIORITY_IDLE = THREAD_BASE_PRIORITY_IDLE
Const THREAD_PRIORITY_NORMAL = 0
Const THREAD_PRIORITY_TIME_CRITICAL = THREAD_BASE_PRIORITY_LOWRT
Const HIGH_PRIORITY_CLASS = &H80
Const IDLE_PRIORITY_CLASS = &H40
Const NORMAL_PRIORITY_CLASS = &H20
Const REALTIME_PRIORITY_CLASS = &H100
Private Declare Function SetThreadPriority Lib "kernel32" (ByVal hThread As Long, ByVal nPriority As Long) As Long
Private Declare Function SetPriorityClass Lib "kernel32" (ByVal hProcess As Long, ByVal dwPriorityClass As Long) As Long
Private Declare Function GetThreadPriority Lib "kernel32" (ByVal hThread As Long) As Long
Private Declare Function GetPriorityClass Lib "kernel32" (ByVal hProcess As Long) As Long
Private Declare Function GetCurrentThread Lib "kernel32" () As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Sub tmBegin()
QueryPerformanceCounter liStart
End Sub
Function tmEnd() As Long
QueryPerformanceCounter liStop
cuStart = LargeIntToCurrency(liStart)
cuStop = LargeIntToCurrency(liStop)
tmEnd = ((cuStop - cuStart) / cuFrequency) * 1000
End Function
Function Init()
If QueryPerformanceFrequency(liFrequency) = 0 Then
MsgBox "Your hardware doesn't support a high-resolution performance counter!", vbInformation
Else
cuFrequency = LargeIntToCurrency(liFrequency)
End If
End Function
Private Function LargeIntToCurrency(liInput As LARGE_INTEGER) As Currency
CopyMemory LargeIntToCurrency, liInput, LenB(liInput)
LargeIntToCurrency = LargeIntToCurrency * 10000
End Function
Private Sub Form_Load()
Dim hThread As Long, hProcess As Long
Dim i As Long
Dim s(1 To 2) As String
hThread = GetCurrentThread
hProcess = GetCurrentProcess
Dim TimerCount As Long, GetTickCountCount As Long, timeGetTimeCount As Long
Dim TimerInterval As Long, GetTickCountInterval As Long, timeGetTimeInterval As Long
Dim l As Single
Init
MsgBox "Подождите 60 секунд!"
For i = 1 To 2
If i = 2 Then
SetThreadPriority hThread, THREAD_PRIORITY_TIME_CRITICAL
SetPriorityClass hProcess, REALTIME_PRIORITY_CLASS
Else
SetThreadPriority hThread, THREAD_PRIORITY_NORMAL
SetPriorityClass hProcess, NORMAL_PRIORITY_CLASS
End If
GetTickCountCount = 0
TimerCount = 0
timeGetTimeCount = 0
l = Timer
tmBegin
Do While Timer - l < 10
TimerCount = TimerCount + 1
Loop
TimerInterval = tmEnd
l = timeGetTime
tmBegin
Do While timeGetTime - l < 10000
timeGetTimeCount = timeGetTimeCount + 1
Loop
timeGetTimeInterval = tmEnd
l = GetTickCount
tmBegin
Do While GetTickCount - l < 10000
GetTickCountCount = GetTickCountCount + 1
Loop
GetTickCountInterval = tmEnd
s(i) = "GetTickCount result: " & Format(GetTickCountCount, "###'###'###") & "(" & GetTickCountInterval & " ms)" & vbCrLf _
& "TimeGetTime result: " & Format(timeGetTimeCount, "###'###'###") & "(" & timeGetTimeInterval & " ms)" & vbCrLf & _
"Timer result: " & Format(TimerCount, "###'###'###") & "(" & TimerInterval & " ms)"
If i = 1 Then MsgBox "Осталось 30 секунд"
Next
MsgBox "Без приоритета реального времени:" & vbCrLf & s(1) & vbcrlf & String(10, "-") & vbCrLf & "С приоритетом реального времени:" & vbCrLf & s(2)
End
End Sub
Option Explicit
Private Declare Function GetTickCount& Lib "kernel32" ()
Private Sub Form_Load()
Dim T&, I&
T = GetTickCount
While GetTickCount - T < 10000
I = I + 1
Wend
MsgBox "Ваш компьютер перерабатывает " & Int(I / 10) & " значений в секунду", vbOKOnly, "CPU Test"
Clipboard.Clear
Clipboard.SetText Int(I / 10)
Unload Me
End Sub
Dim T&, T1&, I&, otv&
T = GetTickCount
For I = 1 To 2147483646
Next I
T1 = (GetTickCount - T)
otv = I / (T1 / 1000)
Clipboard.Clear
Clipboard.SetText otv
MsgBox "Ваш компьютер перерабатывает " & otv & " значений в секунду", vbOKOnly, "CPU Test 2"
CPU Test писал(а):Ваш компьютер перерабатывает 600191070 значений в секунду.
CPU Test писал(а):Ваш компьютер перерабатывает 708506647 значений в секунду.
Сейчас этот форум просматривают: Google-бот и гости: 164