473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

slow reading of eventlog

I need to read the entire eventlog and parse it. The application uses vb.net and the EventLog object. The problem i'm having is that it can take less then a second up to 15 seconds to read all entries in the eventlog. I used Perfmon and found the following two counters that were used heavily

..NET CLR Security Total Runtime Check

..NET CLR Interop # of marshallin

I have written some sample code that shows my problem

Module Module
'<System.Security.SuppressUnmanagedCodeSecurity() >
Sub Main(
'Dim evl As New EventLog("System"
Dim evl As New EventLog("Application"

Dim str As Strin
Dim startTime, endTime As Dat

str = "No entries: " & evl.Entries.Coun
Debug.WriteLine(str
Console.WriteLine(str

For x As Integer = 0 To
startTime = No

For Each entry As EventLogEntry In evl.Entrie
str = entry.UserName & entry.Source & entry.MachineName &
entry.Category & entry.CategoryNumber & entry.EntryType &
entry.EventID & entry.Index & entry.TimeGenerated & entry.Messag
Nex

endTime = No

str = "Started: " & startTime.ToString("HH:mm:ss.ffff") & vbCrLf &
"Ended: " & endTime.ToString("HH:mm:ss.ffff"

Debug.WriteLine(str
Console.WriteLine(str
Nex
End Su
End Modul

When i run it on a P4 machine (3GHz and 2G ram) i get the following results
No entries: 170
Started: 12:04:34.875
Ended: 12:04:38.890

No entries: 193
Started: 12:05:37.937
Ended: 12:05:39.859

Since the application i'm writing is a graphical one i don't want any hangings

Any ideas how i can trim the system or change the code to make it run faster
Nov 22 '05 #1
12 2296
Hi,

Two suggestions.

1) This cuts the run time in half on my system. It is quicker to create a
new string than destroy and create a old one.

For Each entry As EventLogEntry In evl.Entries
Dim strEntry As String
strEntry = String.Format("{0} {1} {2} {3} {4} {5} {6} {7}
{8} {9}", entry.UserName, entry.Source, entry.MachineName, _
entry.Category, entry.CategoryNumber, entry.EntryType,
_
entry.EventID, entry.Index, entry.TimeGenerated,
entry.Message)
Next

No entries: 2055
Started: 06:44:13.2701
Ended: 06:44:16.7451

2) If you are worried about performance process the event log in a seperate
thread.

Ken
-----------------
"zorro" <an*******@discussions.microsoft.com> wrote in message
news:2F**********************************@microsof t.com...
I need to read the entire eventlog and parse it. The application uses
vb.net and the EventLog object. The problem i'm having is that it can take
less then a second up to 15 seconds to read all entries in the eventlog. I
used Perfmon and found the following two counters that were used heavily:

.NET CLR Security Total Runtime Checks

.NET CLR Interop # of marshalling

I have written some sample code that shows my problem:

Module Module1
'<System.Security.SuppressUnmanagedCodeSecurity() > _
Sub Main()
'Dim evl As New EventLog("System")
Dim evl As New EventLog("Application")

Dim str As String
Dim startTime, endTime As Date

str = "No entries: " & evl.Entries.Count
Debug.WriteLine(str)
Console.WriteLine(str)

For x As Integer = 0 To 0
startTime = Now

For Each entry As EventLogEntry In evl.Entries
str = entry.UserName & entry.Source & entry.MachineName & _
entry.Category & entry.CategoryNumber &
entry.EntryType & _
entry.EventID & entry.Index & entry.TimeGenerated &
entry.Message
Next

endTime = Now

str = "Started: " & startTime.ToString("HH:mm:ss.ffff") &
vbCrLf & _
"Ended: " & endTime.ToString("HH:mm:ss.ffff")

Debug.WriteLine(str)
Console.WriteLine(str)
Next
End Sub
End Module

When i run it on a P4 machine (3GHz and 2G ram) i get the following
results:
No entries: 1706
Started: 12:04:34.8750
Ended: 12:04:38.8906

No entries: 1933
Started: 12:05:37.9375
Ended: 12:05:39.8593

Since the application i'm writing is a graphical one i don't want any
hangings.

Any ideas how i can trim the system or change the code to make it run
faster.

Nov 22 '05 #2
Hi,

Two suggestions.

1) This cuts the run time in half on my system. It is quicker to create a
new string than destroy and create a old one.

For Each entry As EventLogEntry In evl.Entries
Dim strEntry As String
strEntry = String.Format("{0} {1} {2} {3} {4} {5} {6} {7}
{8} {9}", entry.UserName, entry.Source, entry.MachineName, _
entry.Category, entry.CategoryNumber, entry.EntryType,
_
entry.EventID, entry.Index, entry.TimeGenerated,
entry.Message)
Next

No entries: 2055
Started: 06:44:13.2701
Ended: 06:44:16.7451

2) If you are worried about performance process the event log in a seperate
thread.

Ken
-----------------
"zorro" <an*******@discussions.microsoft.com> wrote in message
news:2F**********************************@microsof t.com...
I need to read the entire eventlog and parse it. The application uses
vb.net and the EventLog object. The problem i'm having is that it can take
less then a second up to 15 seconds to read all entries in the eventlog. I
used Perfmon and found the following two counters that were used heavily:

.NET CLR Security Total Runtime Checks

.NET CLR Interop # of marshalling

I have written some sample code that shows my problem:

Module Module1
'<System.Security.SuppressUnmanagedCodeSecurity() > _
Sub Main()
'Dim evl As New EventLog("System")
Dim evl As New EventLog("Application")

Dim str As String
Dim startTime, endTime As Date

str = "No entries: " & evl.Entries.Count
Debug.WriteLine(str)
Console.WriteLine(str)

For x As Integer = 0 To 0
startTime = Now

For Each entry As EventLogEntry In evl.Entries
str = entry.UserName & entry.Source & entry.MachineName & _
entry.Category & entry.CategoryNumber &
entry.EntryType & _
entry.EventID & entry.Index & entry.TimeGenerated &
entry.Message
Next

endTime = Now

str = "Started: " & startTime.ToString("HH:mm:ss.ffff") &
vbCrLf & _
"Ended: " & endTime.ToString("HH:mm:ss.ffff")

Debug.WriteLine(str)
Console.WriteLine(str)
Next
End Sub
End Module

When i run it on a P4 machine (3GHz and 2G ram) i get the following
results:
No entries: 1706
Started: 12:04:34.8750
Ended: 12:04:38.8906

No entries: 1933
Started: 12:05:37.9375
Ended: 12:05:39.8593

Since the application i'm writing is a graphical one i don't want any
hangings.

Any ideas how i can trim the system or change the code to make it run
faster.

Nov 22 '05 #3
Hi Zorro,

As an alternative for Ken

For Each entry As EventLogEntry In evl.Entries
dim sb as new system.text.stringbuilder(entry.UserName)
sb.append(entry.Source)
sb.append(etc.)

do it really one by one so also
sb.append("Started: ")
sb.append(Startime.toString)

at the end
str = sb.toString

I am curious which one is the fastest?

Cor
Nov 22 '05 #4
Hi Zorro,

As an alternative for Ken

For Each entry As EventLogEntry In evl.Entries
dim sb as new system.text.stringbuilder(entry.UserName)
sb.append(entry.Source)
sb.append(etc.)

do it really one by one so also
sb.append("Started: ")
sb.append(Startime.toString)

at the end
str = sb.toString

I am curious which one is the fastest?

Cor
Nov 22 '05 #5
Hi,

Two suggestions.

1) This cuts the run time in half on my system. It is quicker to create a
new string than destroy and create a old one.

For Each entry As EventLogEntry In evl.Entries
Dim strEntry As String
strEntry = String.Format("{0} {1} {2} {3} {4} {5} {6} {7}
{8} {9}", entry.UserName, entry.Source, entry.MachineName, _
entry.Category, entry.CategoryNumber, entry.EntryType,
_
entry.EventID, entry.Index, entry.TimeGenerated,
entry.Message)
Next

No entries: 2055
Started: 06:44:13.2701
Ended: 06:44:16.7451

2) If you are worried about performance process the event log in a seperate
thread.

Ken
-----------------
"zorro" <an*******@discussions.microsoft.com> wrote in message
news:2F**********************************@microsof t.com...
I need to read the entire eventlog and parse it. The application uses
vb.net and the EventLog object. The problem i'm having is that it can take
less then a second up to 15 seconds to read all entries in the eventlog. I
used Perfmon and found the following two counters that were used heavily:

.NET CLR Security Total Runtime Checks

.NET CLR Interop # of marshalling

I have written some sample code that shows my problem:

Module Module1
'<System.Security.SuppressUnmanagedCodeSecurity() > _
Sub Main()
'Dim evl As New EventLog("System")
Dim evl As New EventLog("Application")

Dim str As String
Dim startTime, endTime As Date

str = "No entries: " & evl.Entries.Count
Debug.WriteLine(str)
Console.WriteLine(str)

For x As Integer = 0 To 0
startTime = Now

For Each entry As EventLogEntry In evl.Entries
str = entry.UserName & entry.Source & entry.MachineName & _
entry.Category & entry.CategoryNumber &
entry.EntryType & _
entry.EventID & entry.Index & entry.TimeGenerated &
entry.Message
Next

endTime = Now

str = "Started: " & startTime.ToString("HH:mm:ss.ffff") &
vbCrLf & _
"Ended: " & endTime.ToString("HH:mm:ss.ffff")

Debug.WriteLine(str)
Console.WriteLine(str)
Next
End Sub
End Module

When i run it on a P4 machine (3GHz and 2G ram) i get the following
results:
No entries: 1706
Started: 12:04:34.8750
Ended: 12:04:38.8906

No entries: 1933
Started: 12:05:37.9375
Ended: 12:05:39.8593

Since the application i'm writing is a graphical one i don't want any
hangings.

Any ideas how i can trim the system or change the code to make it run
faster.

Nov 22 '05 #6
wellwell
a post of me long time ago:

after the very small & vs string.format discussion I did some speed tests...
loop of 1.000.000 concatenations of 5 public string variables in a class
gave following results:
result = a & b & c & d & e
+/- 420ms

result = a
result &= b
result &= c
result &= d
result &= e
+/- 370ms

dim result as new StringBuilder()
result.Append(a)
result.Append(b)
result.Append(c)
result.Append(d)
result.Append(e)
new StringBuilder in each loop: +/- 730ms
new StringBuilder outside + result.length=0 in each loop: +/- 690ms

result = String.Format("{0}{1}{2}{3}{4}", a, b, c, d, e)
+/- 1540ms
so in my opinion, only use string.format to do real formatting :-)
the difference between the first 2 seems strange to me
is this a compiler problem?
oh yes, everything was ran in debug mode in visual studio 2003...
dominique


Nov 22 '05 #7
wellwell
a post of me long time ago:

after the very small & vs string.format discussion I did some speed tests...
loop of 1.000.000 concatenations of 5 public string variables in a class
gave following results:
result = a & b & c & d & e
+/- 420ms

result = a
result &= b
result &= c
result &= d
result &= e
+/- 370ms

dim result as new StringBuilder()
result.Append(a)
result.Append(b)
result.Append(c)
result.Append(d)
result.Append(e)
new StringBuilder in each loop: +/- 730ms
new StringBuilder outside + result.length=0 in each loop: +/- 690ms

result = String.Format("{0}{1}{2}{3}{4}", a, b, c, d, e)
+/- 1540ms
so in my opinion, only use string.format to do real formatting :-)
the difference between the first 2 seems strange to me
is this a compiler problem?
oh yes, everything was ran in debug mode in visual studio 2003...
dominique


Nov 22 '05 #8
Hi Zorro,

As an alternative for Ken

For Each entry As EventLogEntry In evl.Entries
dim sb as new system.text.stringbuilder(entry.UserName)
sb.append(entry.Source)
sb.append(etc.)

do it really one by one so also
sb.append("Started: ")
sb.append(Startime.toString)

at the end
str = sb.toString

I am curious which one is the fastest?

Cor
Nov 22 '05 #9
wellwell
a post of me long time ago:

after the very small & vs string.format discussion I did some speed tests...
loop of 1.000.000 concatenations of 5 public string variables in a class
gave following results:
result = a & b & c & d & e
+/- 420ms

result = a
result &= b
result &= c
result &= d
result &= e
+/- 370ms

dim result as new StringBuilder()
result.Append(a)
result.Append(b)
result.Append(c)
result.Append(d)
result.Append(e)
new StringBuilder in each loop: +/- 730ms
new StringBuilder outside + result.length=0 in each loop: +/- 690ms

result = String.Format("{0}{1}{2}{3}{4}", a, b, c, d, e)
+/- 1540ms
so in my opinion, only use string.format to do real formatting :-)
the difference between the first 2 seems strange to me
is this a compiler problem?
oh yes, everything was ran in debug mode in visual studio 2003...
dominique


Nov 22 '05 #10
Hi Dominique,

I tested it and the test is bellow.

With short strings I had almost the same results as you.
Although using the SB was the fastest while the concatanation of short
strings in line was almost the same.

What was also slightly different with me was that the creation of the SB
inside the loop the time was twice as much as with setting the length to 0,
(that test with new SB is not included).

However when the strings become longer, what is in the end of the test, I
had to bring the test down to 1000 loops when I did not wanted to wait to
long using something other than the stringbuilder.

Maybe you can have a look at it and when I did test something wrong tell me?

Cor

Module Teststrings
Public Sub main()
Dim arl As New ArrayList
arl.Add("This is string one")
arl.Add("This is string two")
arl.Add("This is string three")
arl.Add("This is string four")
arl.Add("This is string five")
arl.Add("This is string six")
arl.Add("This is string seven")
arl.Add("This is string eight")
arl.Add("This is string nine")
arl.Add("This is string ten")
Dim str As String
Dim start As Integer = Environment.TickCount
Dim sb As New System.Text.StringBuilder("")
For i As Integer = 0 To 100000
sb.Length = 0
sb.Append(arl(0).ToString)
sb.Append(arl(1).ToString)
sb.Append(arl(2).ToString)
sb.Append(arl(3).ToString)
sb.Append(arl(4).ToString)
sb.Append(arl(5).ToString)
sb.Append(arl(6).ToString)
sb.Append(arl(7).ToString)
sb.Append(arl(8).ToString)
sb.Append(arl(9).ToString)
Next
str = sb.ToString
MessageBox.Show("Short strings with stringbuilder: " & _
(Environment.TickCount - start).ToString)
start = Environment.TickCount
For i As Integer = 0 To 100000
str = arl(0).ToString & arl(1).ToString & arl(3).ToString _
& arl(4).ToString & arl(5).ToString & _
arl(6).ToString & arl(7).ToString & arl(8).ToString &
arl(9).ToString
Next
MessageBox.Show("Short strings with concat in row: " & _
(Environment.TickCount - start).ToString)
start = Environment.TickCount
For i As Integer = 0 To 100000
str = arl(0).ToString
str &= arl(1).ToString
str &= arl(2).ToString
str &= arl(3).ToString
str &= arl(4).ToString
str &= arl(5).ToString
str &= arl(6).ToString
str &= arl(7).ToString
str &= arl(8).ToString
str &= arl(9).ToString
Next
MessageBox.Show("Short strings with concat row by row: " _
& (Environment.TickCount - start).ToString)
start = Environment.TickCount
For i As Integer = 0 To 100000
str = str.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9 }",
arl(0).ToString, _
arl(1).ToString, arl(2).ToString, arl(3).ToString,
arl(4).ToString, arl(5).ToString, _
arl(6).ToString, arl(7).ToString, arl(8).ToString,
arl(9).ToString)
Next
MessageBox.Show("Short strings with format :" & _
(Environment.TickCount - start).ToString)
'Concetanation
start = Environment.TickCount
sb.Length = 0
For i As Integer = 0 To 1000
sb.Append(arl(0).ToString)
sb.Append(arl(1).ToString)
sb.Append(arl(2).ToString)
sb.Append(arl(3).ToString)
sb.Append(arl(4).ToString)
sb.Append(arl(5).ToString)
sb.Append(arl(6).ToString)
sb.Append(arl(7).ToString)
sb.Append(arl(8).ToString)
sb.Append(arl(9).ToString)
Next
str = sb.ToString
MessageBox.Show("Building a long string with sb : " & _
(Environment.TickCount - start).ToString)
str = ""
start = Environment.TickCount
For i As Integer = 0 To 1000
str &= arl(0).ToString & arl(1).ToString & _
arl(3).ToString & arl(4).ToString & arl(5).ToString & _
arl(6).ToString & arl(7).ToString & arl(8).ToString &
arl(9).ToString
Next
MessageBox.Show("Building a long string with concat in a row : " _
& (Environment.TickCount - start).ToString)
start = Environment.TickCount
str = ""
For i As Integer = 0 To 1000
str &= arl(0).ToString
str &= arl(1).ToString
str &= arl(2).ToString
str &= arl(3).ToString
str &= arl(4).ToString
str &= arl(5).ToString
str &= arl(6).ToString
str &= arl(7).ToString
str &= arl(8).ToString
str &= arl(9).ToString
Next
MessageBox.Show("Building a long string with concat : " _
& (Environment.TickCount - start).ToString)
start = Environment.TickCount
str = ""
For i As Integer = 0 To 1000
str &= str.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9 }", _
arl(0).ToString, arl(1).ToString, arl(2).ToString, _
arl(3).ToString, arl(4).ToString, arl(5).ToString, _
arl(6).ToString, arl(7).ToString, arl(8).ToString,
arl(9).ToString)
Next
MessageBox.Show("Building a long string with format : " _
& (Environment.TickCount - start).ToString)
End Sub
End Module
Nov 22 '05 #11
Hi Dominique,

I tested it and the test is bellow.

With short strings I had almost the same results as you.
Although using the SB was the fastest while the concatanation of short
strings in line was almost the same.

What was also slightly different with me was that the creation of the SB
inside the loop the time was twice as much as with setting the length to 0,
(that test with new SB is not included).

However when the strings become longer, what is in the end of the test, I
had to bring the test down to 1000 loops when I did not wanted to wait to
long using something other than the stringbuilder.

Maybe you can have a look at it and when I did test something wrong tell me?

Cor

Module Teststrings
Public Sub main()
Dim arl As New ArrayList
arl.Add("This is string one")
arl.Add("This is string two")
arl.Add("This is string three")
arl.Add("This is string four")
arl.Add("This is string five")
arl.Add("This is string six")
arl.Add("This is string seven")
arl.Add("This is string eight")
arl.Add("This is string nine")
arl.Add("This is string ten")
Dim str As String
Dim start As Integer = Environment.TickCount
Dim sb As New System.Text.StringBuilder("")
For i As Integer = 0 To 100000
sb.Length = 0
sb.Append(arl(0).ToString)
sb.Append(arl(1).ToString)
sb.Append(arl(2).ToString)
sb.Append(arl(3).ToString)
sb.Append(arl(4).ToString)
sb.Append(arl(5).ToString)
sb.Append(arl(6).ToString)
sb.Append(arl(7).ToString)
sb.Append(arl(8).ToString)
sb.Append(arl(9).ToString)
Next
str = sb.ToString
MessageBox.Show("Short strings with stringbuilder: " & _
(Environment.TickCount - start).ToString)
start = Environment.TickCount
For i As Integer = 0 To 100000
str = arl(0).ToString & arl(1).ToString & arl(3).ToString _
& arl(4).ToString & arl(5).ToString & _
arl(6).ToString & arl(7).ToString & arl(8).ToString &
arl(9).ToString
Next
MessageBox.Show("Short strings with concat in row: " & _
(Environment.TickCount - start).ToString)
start = Environment.TickCount
For i As Integer = 0 To 100000
str = arl(0).ToString
str &= arl(1).ToString
str &= arl(2).ToString
str &= arl(3).ToString
str &= arl(4).ToString
str &= arl(5).ToString
str &= arl(6).ToString
str &= arl(7).ToString
str &= arl(8).ToString
str &= arl(9).ToString
Next
MessageBox.Show("Short strings with concat row by row: " _
& (Environment.TickCount - start).ToString)
start = Environment.TickCount
For i As Integer = 0 To 100000
str = str.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9 }",
arl(0).ToString, _
arl(1).ToString, arl(2).ToString, arl(3).ToString,
arl(4).ToString, arl(5).ToString, _
arl(6).ToString, arl(7).ToString, arl(8).ToString,
arl(9).ToString)
Next
MessageBox.Show("Short strings with format :" & _
(Environment.TickCount - start).ToString)
'Concetanation
start = Environment.TickCount
sb.Length = 0
For i As Integer = 0 To 1000
sb.Append(arl(0).ToString)
sb.Append(arl(1).ToString)
sb.Append(arl(2).ToString)
sb.Append(arl(3).ToString)
sb.Append(arl(4).ToString)
sb.Append(arl(5).ToString)
sb.Append(arl(6).ToString)
sb.Append(arl(7).ToString)
sb.Append(arl(8).ToString)
sb.Append(arl(9).ToString)
Next
str = sb.ToString
MessageBox.Show("Building a long string with sb : " & _
(Environment.TickCount - start).ToString)
str = ""
start = Environment.TickCount
For i As Integer = 0 To 1000
str &= arl(0).ToString & arl(1).ToString & _
arl(3).ToString & arl(4).ToString & arl(5).ToString & _
arl(6).ToString & arl(7).ToString & arl(8).ToString &
arl(9).ToString
Next
MessageBox.Show("Building a long string with concat in a row : " _
& (Environment.TickCount - start).ToString)
start = Environment.TickCount
str = ""
For i As Integer = 0 To 1000
str &= arl(0).ToString
str &= arl(1).ToString
str &= arl(2).ToString
str &= arl(3).ToString
str &= arl(4).ToString
str &= arl(5).ToString
str &= arl(6).ToString
str &= arl(7).ToString
str &= arl(8).ToString
str &= arl(9).ToString
Next
MessageBox.Show("Building a long string with concat : " _
& (Environment.TickCount - start).ToString)
start = Environment.TickCount
str = ""
For i As Integer = 0 To 1000
str &= str.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9 }", _
arl(0).ToString, arl(1).ToString, arl(2).ToString, _
arl(3).ToString, arl(4).ToString, arl(5).ToString, _
arl(6).ToString, arl(7).ToString, arl(8).ToString,
arl(9).ToString)
Next
MessageBox.Show("Building a long string with format : " _
& (Environment.TickCount - start).ToString)
End Sub
End Module
Nov 22 '05 #12
Hi Dominique,

I tested it and the test is bellow.

With short strings I had almost the same results as you.
Although using the SB was the fastest while the concatanation of short
strings in line was almost the same.

What was also slightly different with me was that the creation of the SB
inside the loop the time was twice as much as with setting the length to 0,
(that test with new SB is not included).

However when the strings become longer, what is in the end of the test, I
had to bring the test down to 1000 loops when I did not wanted to wait to
long using something other than the stringbuilder.

Maybe you can have a look at it and when I did test something wrong tell me?

Cor

Module Teststrings
Public Sub main()
Dim arl As New ArrayList
arl.Add("This is string one")
arl.Add("This is string two")
arl.Add("This is string three")
arl.Add("This is string four")
arl.Add("This is string five")
arl.Add("This is string six")
arl.Add("This is string seven")
arl.Add("This is string eight")
arl.Add("This is string nine")
arl.Add("This is string ten")
Dim str As String
Dim start As Integer = Environment.TickCount
Dim sb As New System.Text.StringBuilder("")
For i As Integer = 0 To 100000
sb.Length = 0
sb.Append(arl(0).ToString)
sb.Append(arl(1).ToString)
sb.Append(arl(2).ToString)
sb.Append(arl(3).ToString)
sb.Append(arl(4).ToString)
sb.Append(arl(5).ToString)
sb.Append(arl(6).ToString)
sb.Append(arl(7).ToString)
sb.Append(arl(8).ToString)
sb.Append(arl(9).ToString)
Next
str = sb.ToString
MessageBox.Show("Short strings with stringbuilder: " & _
(Environment.TickCount - start).ToString)
start = Environment.TickCount
For i As Integer = 0 To 100000
str = arl(0).ToString & arl(1).ToString & arl(3).ToString _
& arl(4).ToString & arl(5).ToString & _
arl(6).ToString & arl(7).ToString & arl(8).ToString &
arl(9).ToString
Next
MessageBox.Show("Short strings with concat in row: " & _
(Environment.TickCount - start).ToString)
start = Environment.TickCount
For i As Integer = 0 To 100000
str = arl(0).ToString
str &= arl(1).ToString
str &= arl(2).ToString
str &= arl(3).ToString
str &= arl(4).ToString
str &= arl(5).ToString
str &= arl(6).ToString
str &= arl(7).ToString
str &= arl(8).ToString
str &= arl(9).ToString
Next
MessageBox.Show("Short strings with concat row by row: " _
& (Environment.TickCount - start).ToString)
start = Environment.TickCount
For i As Integer = 0 To 100000
str = str.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9 }",
arl(0).ToString, _
arl(1).ToString, arl(2).ToString, arl(3).ToString,
arl(4).ToString, arl(5).ToString, _
arl(6).ToString, arl(7).ToString, arl(8).ToString,
arl(9).ToString)
Next
MessageBox.Show("Short strings with format :" & _
(Environment.TickCount - start).ToString)
'Concetanation
start = Environment.TickCount
sb.Length = 0
For i As Integer = 0 To 1000
sb.Append(arl(0).ToString)
sb.Append(arl(1).ToString)
sb.Append(arl(2).ToString)
sb.Append(arl(3).ToString)
sb.Append(arl(4).ToString)
sb.Append(arl(5).ToString)
sb.Append(arl(6).ToString)
sb.Append(arl(7).ToString)
sb.Append(arl(8).ToString)
sb.Append(arl(9).ToString)
Next
str = sb.ToString
MessageBox.Show("Building a long string with sb : " & _
(Environment.TickCount - start).ToString)
str = ""
start = Environment.TickCount
For i As Integer = 0 To 1000
str &= arl(0).ToString & arl(1).ToString & _
arl(3).ToString & arl(4).ToString & arl(5).ToString & _
arl(6).ToString & arl(7).ToString & arl(8).ToString &
arl(9).ToString
Next
MessageBox.Show("Building a long string with concat in a row : " _
& (Environment.TickCount - start).ToString)
start = Environment.TickCount
str = ""
For i As Integer = 0 To 1000
str &= arl(0).ToString
str &= arl(1).ToString
str &= arl(2).ToString
str &= arl(3).ToString
str &= arl(4).ToString
str &= arl(5).ToString
str &= arl(6).ToString
str &= arl(7).ToString
str &= arl(8).ToString
str &= arl(9).ToString
Next
MessageBox.Show("Building a long string with concat : " _
& (Environment.TickCount - start).ToString)
start = Environment.TickCount
str = ""
For i As Integer = 0 To 1000
str &= str.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9 }", _
arl(0).ToString, arl(1).ToString, arl(2).ToString, _
arl(3).ToString, arl(4).ToString, arl(5).ToString, _
arl(6).ToString, arl(7).ToString, arl(8).ToString,
arl(9).ToString)
Next
MessageBox.Show("Building a long string with format : " _
& (Environment.TickCount - start).ToString)
End Sub
End Module
Nov 22 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sauron | last post by:
Hi all I have created a Service that will listen for incoming requests from client computers and communicate with my .NET remoting objects to send data back. My problem is when I start the...
0
by: zorro | last post by:
I need to read the entire eventlog and parse it. The application uses vb.net and the EventLog object. The problem i'm having is that it can take less then a second up to 15 seconds to read all...
3
by: | last post by:
I'm changing passwords every so often with my VB.net app using the NetUserSetInfo API call. I found that it is very slow, on a 3 GHz P4 it uses 18 seconds to change 100 passwords. Anyone else have...
4
by: Greg Smith | last post by:
I have an old application that analyzes the data in the event log on one of our servers. I would like to convert it to C#. Does anybody know of any examples of reading the event log on a remote...
0
by: sangui | last post by:
..Net provide the class to read eventlog (EventLog class) but I try to read the window eventlog per file. without using EventLog Class. is it possible to read the log per file? public...
2
by: Next | last post by:
Hello all, I have a windows service that was suppose to write some events into its own EventLog. I created the EventLog using the component on VS 2003 toolbar Added an installer for it. Set...
3
by: Ahmad Jalil Qarshi | last post by:
Hi! I am developing an application in C# as a windows NT Service. This application needs to check for eventlog using EventLog.Exists("System") But unfortunately it generates exception...
1
by: hecsan07 | last post by:
Hey I am trying to read the Windows Event Logc. In fact, I am able to read the Event Log. My problem is that I am reading and filtering a large log and it takes a very very very very long time...
1
by: martin | last post by:
Hi, I'm having some problems with the System.Diagnostics.EventLog class in .NET 2.0 I need to recreate an event message source inside a new log but the messages keeps ending up in the old...
3
by: Ben | last post by:
I am trying to write an eventlog monitor. I am using the sample code provided by VB2005 SDK as the bases for my application. I need to monitor all three logs (application, system, and security)....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.