Option Public
Option Declare
Sub Initialize
' test_doc_GetItemValue
' test_doc_ReplaceItemValue
' test_sub_or_function
' test_forall
' test_Appen_and_Remove_Item
' test_doc_CreateNew
' test_RTItem_CreateNew
test_NotesDateTime_CreateNew
End Sub
Function test_doc_GetItemValue
'данный тест сравнивает doc.GetItemValue("Field") и doc.Field
Const count = 100000
Print "___"
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.CurrentDatabase
Dim doc As NotesDocument
Set doc = New NotesDocument(db)
Call doc.ReplaceItemValue("Field", "")
Call test_doc_GetItemValue_DocGet(count, doc)
Call test_doc_GetItemValue_DocFld(count, doc)
End Function
Function test_doc_GetItemValue_DocGet(count As Long, doc As NotesDocument)
Dim v As Variant
Dim startTime As Single
Dim endTime As Single
Dim i As Long
startTime = Timer()
For i = 0 To count
v = doc.GetItemValue("Field")
Next
endTime = Timer()
Print Cstr(Getthreadinfo(1)) & ". Timer = " & Format(endTime - startTime, "0.00000000") & " sec."
End Function
Function test_doc_GetItemValue_DocFld(count As Long, doc As NotesDocument)
Dim v As Variant
Dim startTime As Single
Dim endTime As Single
Dim i As Long
startTime = Timer()
For i = 0 To count
v = doc.Field
Next
endTime = Timer()
Print Cstr(Getthreadinfo(1)) & ". Timer = " & Format(endTime - startTime, "0.00000000") & " sec."
End Function
Function test_doc_ReplaceItemValue
'данный тест сравнивает doc.ReplaceItemValue("Field", value) и doc.Field = value
Const count = 100000
Print "___"
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.CurrentDatabase
Dim doc As NotesDocument
Set doc = New NotesDocument(db)
Call doc.ReplaceItemValue("Field", "")
Call test_doc_ReplaceItemValue_DocFld(count, doc)
Call test_doc_ReplaceItemValue_DocRepl(count, doc)
End Function
Function test_doc_ReplaceItemValue_DocRepl(count As Long, doc As NotesDocument)
Dim v As Variant
Dim startTime As Single
Dim endTime As Single
Dim i As Long
startTime = Timer()
For i = 0 To count
Call doc.ReplaceItemValue("Field", i)
Next
endTime = Timer()
Print Cstr(Getthreadinfo(1)) & ". Timer = " & Format(endTime - startTime, "0.00000000") & " sec."
End Function
Function test_doc_ReplaceItemValue_DocFld(count As Long, doc As NotesDocument)
Dim v As Variant
Dim startTime As Single
Dim endTime As Single
Dim i As Long
startTime = Timer()
For i = 0 To count
doc.Field = i
Next
endTime = Timer()
Print Cstr(Getthreadinfo(1)) & ". Timer = " & Format(endTime - startTime, "0.00000000") & " sec."
End Function
Function test_sub_or_function()
'данный тест сравнивает вызов функции и процедуры
Const count = 2000000
Print "___"
Call test_sub_or_function_F(count)
Call test_sub_or_function_S(count)
Call test_sub_or_function_F(count)
Call test_sub_or_function_S(count)
Call test_sub_or_function_F(count)
Call test_sub_or_function_S(count)
Call test_sub_or_function_F(count)
End Function
Function test_sub_or_function_F(count As Long)
Dim s As String
Dim startTime As Single
Dim endTime As Single
Dim i As Long
s = ""
startTime = Timer()
For i = 0 To count
Call test_sub_or_function_function
Next
endTime = Timer()
Print Cstr(Getthreadinfo(1)) & ". Timer = " & Format(endTime - startTime, "0.00000000") & " sec."
End Function
Function test_sub_or_function_S(count As Long)
Dim s As String
Dim startTime As Single
Dim endTime As Single
Dim i As Long
s = ""
startTime = Timer()
For i = 0 To count
Call test_sub_or_function_sub
Next
endTime = Timer()
Print Cstr(Getthreadinfo(1)) & ". Timer = " & Format(endTime - startTime, "0.00000000") & " sec."
End Function
Function test_sub_or_function_function() As Integer
Dim i As Long
i = 0
End Function
Sub test_sub_or_function_sub()
Dim i As Long
i = 0
End Sub
Sub test_forall
'данный тест сравнивает forall, for i = 0 To count, for i = 0 To Ubound()
Const count = 100 '2000
Print "___"
Call test_forall_forall(count)
Call test_forall_for_i_to_count(count)
Call test_forall_for_i_to_ubound(count)
End Sub
Sub test_forall_forall(count As Long)
Redim m(32767) As Long
Dim startTime As Single
Dim endTime As Single
Dim i As Long
startTime = Timer()
For i = 0 To count
Forall mm In m
mm = 1
End Forall
Next
endTime = Timer()
Print Cstr(Getthreadinfo(1)) & ". Timer = " & Format(endTime - startTime, "0.00000000") & " sec."
End Sub
Sub test_forall_for_i_to_count(count As Long)
Redim m(32767) As Long
Dim i As Long, j As Long
Dim startTime As Single
Dim endTime As Single
startTime = Timer()
For i = 0 To count
For j = 0 To 32767
m(j) = 1
Next
Next
endTime = Timer()
Print Cstr(Getthreadinfo(1)) & ". Timer = " & Format(endTime - startTime, "0.00000000") & " sec."
End Sub
Sub test_forall_for_i_to_ubound(count As Long)
Redim m(32767) As Long
Dim i As Long, j As Long
Dim startTime As Single
Dim endTime As Single
startTime = Timer()
For i = 0 To count
For j = 0 To Ubound(m)
m(j) = 1
Next
Next
endTime = Timer()
Print Cstr(Getthreadinfo(1)) & ". Timer = " & Format(endTime - startTime, "0.00000000") & " sec."
End Sub
Sub test_Appen_and_Remove_Item
Print "--------------"
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.CurrentDatabase
Dim doc As New NotesDocument(db)
Dim item As NotesItem
Const itemName = "i1"
Call doc.AppendItemValue(itemName, "1")
Call doc.AppendItemValue(itemName, "2")
Call doc.AppendItemValue(itemName, "3")
Set item = doc.GetFirstItem(itemName)
Do Until item Is Nothing
Print {item.Text = } + Item.Text
Set item = doc.GetNextItem(item)
Loop
Do While doc.HasItem(itemName)
Print {item.Text = } '+ doc.GetFirstItem(itemName).Text 'если здесь закомментировать от плюса, цикл выполнится один раз
Call doc.GetFirstItem(itemName).remove()
Loop
End Sub
Sub test_doc_CreateNew
'данный тест сравнивает db.CreateDocument и New NotesDocument(db)
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.CurrentDatabase
Const count =100000
Print "___"
Call test_doc_CreateNew_Cre(count, db) 'первый всегда медленно
Call test_doc_CreateNew_New(count, db)
Call test_doc_CreateNew_Cre(count, db)
End Sub
Sub test_doc_CreateNew_Cre(count As Long, db As NotesDatabase)
Dim doc As NotesDocument
Dim startTime As Single
Dim endTime As Single
Dim i As Long
startTime = Timer()
For i = 0 To count
Set doc = db.CreateDocument
' Delete doc
Next
endTime = Timer()
Print Cstr(Getthreadinfo(1)) & ". Timer = " & Format(endTime - startTime, "0.00000000") & " sec."
End Sub
Sub test_doc_CreateNew_New(count As Long, db As NotesDatabase)
Dim doc As NotesDocument
Dim startTime As Single
Dim endTime As Single
Dim i As Long
startTime = Timer()
For i = 0 To count
Set doc = New NotesDocument(db)
' Delete doc
Next
endTime = Timer()
Print Cstr(Getthreadinfo(1)) & ". Timer = " & Format(endTime - startTime, "0.00000000") & " sec."
End Sub
Sub test_RTItem_CreateNew
'данный тест сравнивает doc.CreateRichTextItem("Body") и New NotesRichTextItem(doc, "Body")
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.CurrentDatabase
Dim doc As NotesDocument
Set doc = db.CreateDocument
Const count = 100000
Print "___"
Call test_RTItem_CreateNew_Cre(count, doc) 'первый всегда медленно
Call test_RTItem_CreateNew_New(count, doc)
Call test_RTItem_CreateNew_Cre(count, doc)
Call test_RTItem_CreateNew_New(count, doc)
Call test_RTItem_CreateNew_Cre(count, doc)
End Sub
Sub test_RTItem_CreateNew_Cre(count, doc As NotesDocument)
Dim rti As NotesRichTextItem
Dim startTime As Single
Dim endTime As Single
Dim i As Long
startTime = Timer()
For i = 0 To count
Set rti = doc.CreateRichTextItem("Body")
Call rti.remove()
Next
endTime = Timer()
Print Cstr(Getthreadinfo(1)) & ". Timer = " & Format(endTime - startTime, "0.00000000") & " sec."
End Sub
Sub test_RTItem_CreateNew_New(count, doc As NotesDocument)
Dim rti As NotesRichTextItem
Dim startTime As Single
Dim endTime As Single
Dim i As Long
startTime = Timer()
For i = 0 To count
Set rti = New NotesRichTextItem(doc, "Body")
Call rti.remove()
Next
endTime = Timer()
Print Cstr(Getthreadinfo(1)) & ". Timer = " & Format(endTime - startTime, "0.00000000") & " sec."
End Sub
Sub test_NotesDateTime_CreateNew
'данный тест сравнивает session.CreateDateTime("") и New NotesDateTime("")
Dim s As New NotesSession
Const count = 500000
Print "___"
Call test_NotesDateTime_CreateNew_Cre(count, s) 'первый всегда медленно
Call test_NotesDateTime_CreateNew_New(count, s)
Call test_NotesDateTime_CreateNew_Cre(count, s)
Call test_NotesDateTime_CreateNew_New(count, s)
Call test_NotesDateTime_CreateNew_Cre(count, s)
End Sub
Sub test_NotesDateTime_CreateNew_Cre(count As Long, s As NotesSession)
Dim dt As NotesDateTime
Dim startTime As Single
Dim endTime As Single
Dim i As Long
startTime = Timer()
For i = 0 To count
Set dt = s.CreateDateTime("")
Next
endTime = Timer()
Print Cstr(Getthreadinfo(1)) & ". Timer = " & Format(endTime - startTime, "0.00000000") & " sec."
End Sub
Sub test_NotesDateTime_CreateNew_New(count As Long, s As NotesSession)
Dim dt As NotesDateTime
Dim startTime As Single
Dim endTime As Single
Dim i As Long
startTime = Timer()
For i = 0 To count
Set dt = New NotesDateTime("")
Next
endTime = Timer()
Print Cstr(Getthreadinfo(1)) & ". Timer = " & Format(endTime - startTime, "0.00000000") & " sec."
End Sub