VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Form1"
ClientHeight = 3465
ClientLeft = 45
ClientTop = 330
ClientWidth = 5520
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3465
ScaleWidth = 5520
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdClear
Caption = "Borrar listas"
Height = 255
Left = 3720
TabIndex = 11
Top = 120
Width = 1695
End
Begin VB.TextBox txtRep
Height = 285
Left = 2160
TabIndex = 10
Text = "Text1"
Top = 120
Width = 1455
End
Begin VB.ListBox lstTiempos
Height = 2010
Index = 2
Left = 3720
TabIndex = 7
Top = 960
Width = 1695
End
Begin VB.CommandButton cmdOpciones
Caption = "Locales"
Height = 375
Index = 2
Left = 3720
TabIndex = 6
Top = 480
Width = 1695
End
Begin VB.ListBox lstTiempos
Height = 2010
Index = 1
Left = 1920
TabIndex = 4
Top = 960
Width = 1695
End
Begin VB.CommandButton cmdOpciones
Caption = "Globales"
Height = 375
Index = 1
Left = 1920
TabIndex = 3
Top = 480
Width = 1695
End
Begin VB.ListBox lstTiempos
Height = 2010
Index = 0
Left = 120
TabIndex = 1
Top = 960
Width = 1695
End
Begin VB.CommandButton cmdOpciones
Caption = "Publicas"
Height = 375
Index = 0
Left = 120
TabIndex = 0
Top = 480
Width = 1695
End
Begin VB.Label Label2
BorderStyle = 1 'Fixed Single
Caption = "Número de repeticiones:"
Height = 285
Left = 120
TabIndex = 9
Top = 120
Width = 2055
End
Begin VB.Label lblPromedio
BorderStyle = 1 'Fixed Single
Caption = "Promedio:"
Height = 255
Index = 2
Left = 3720
TabIndex = 8
Top = 3120
Width = 1695
End
Begin VB.Label lblPromedio
BorderStyle = 1 'Fixed Single
Caption = "Promedio:"
Height = 255
Index = 1
Left = 1920
TabIndex = 5
Top = 3120
Width = 1695
End
Begin VB.Label lblPromedio
BorderStyle = 1 'Fixed Single
Caption = "Promedio:"
Height = 255
Index = 0
Left = 120
TabIndex = 2
Top = 3120
Width = 1695
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim TpoTotal&
Dim gVariable%
Private Sub cmdClear_Click()
Dim i%
For i = 0 To 2
lstTiempos(i).Clear
Next
End Sub
Private Sub cmdOpciones_Click(Index As Integer)
Dim Tpo! 'Para contar el tiempo
Dim i&, j& 'Para el for
Dim lVariable%
MousePointer = 11
Tpo = Timer
Select Case Index
Case 0 'Publica
For i = 0 To TpoTotal
For j = 0 To 1000
If pVariable Then pVariable = pVariable
Next
Next
Case 1 'Global
For i = 0 To TpoTotal
For j = 0 To 1000
If gVariable Then gVariable = gVariable
Next
Next
Case 2 'Local
For i = 0 To TpoTotal
For j = 0 To 1000
If lVariable Then lVariable = lVariable
Next
Next
End Select
Tpo = Timer - Tpo
MousePointer = 0
If Tpo < 0.1 Then
MsgBox "El resultado no es confiable y está afectado de errores." & vbNewLine & "Se aumentó el número repeticiones del bucle", vbExclamation
If Tpo < 0 Then
txtRep = TpoTotal * 100
Else
txtRep = CLng(TpoTotal * 0.5 / Tpo)
End If
cmdClear_Click
Exit Sub
End If
lstTiempos(Index).AddItem Tpo
Tpo = 0
For i = 0 To lstTiempos(Index).ListCount - 1
Tpo = Tpo + lstTiempos(Index).List(i)
Next
lblPromedio(Index) = "Promedio: " & Tpo / lstTiempos(Index).ListCount
End Sub
Private Sub Form_Load()
'Método casero para "Afinar" el numero total del bucle
'Intento hacerlo independiente del procesador
Dim k&
Dim Tpo! 'Para contar el tiempo
Dim i&, j& 'Para el for
k = 1
Do
Tpo = Timer
For i = 0 To 10000 * k
For j = 0 To 1000
If pVariable Then pVariable = pVariable
Next
Next
Tpo = Timer - Tpo
TpoTotal = 10000 * k / Tpo
k = k * 10
Loop While TpoTotal < 0
txtRep = TpoTotal
End Sub
Private Sub txtRep_Change()
TpoTotal = txtRep
End Sub