F
Frank
Hello all, I'm new here and I've searched a lot before posting my question,
but I can't seem to find a solution to my problem.
I'm working on a database program that I created myself, I created my own
file format and I store information about clients in there. So far, so good,
but when I try to search the content of my file, that's where it becomes
slow....I try to check if a byte is > than 0 in every client's
profile....there are 100 000 clients and the file size is about 200mb.
It goes something like this....
Dim objFile As New System.IO.FileStream("Clients.pcf", IO.FileMode.Open)
For i = 0 To 99999
If Results(i) Then
objFile.Position = (Jump * i) + position
If objFile.ReadByte() > 0 Then
Results(i) = False
End If
End If
Next
Results() is an array of Bool and is used to indicate if the client matches
what I'm looking for. It is used several times by different Subs and passed
as an argument.
Jump indicates the length of each client's profile in bytes.
Position indicates where the information is located within the client's
profile.
My computer is old (1gHz), but still, a task like that takes almost 30
seconds...I found out that this line slows everything down: objFile.Position
= (Jump * i) + position, but a multiplication is not supposed to take that
long (I've tried it separately) and if I click a second time on the button
that handles that event, it takes less that a second to get my results....
I've even looked at the CPU usage and it goes up only for the
second....what's happening? Is VB copying my file somewhere?
I must say that I'm more that confused right now....I'm sorry if this is a
long post, but it's a pretty complex situation and I would appreciate every
suggestion.
but I can't seem to find a solution to my problem.
I'm working on a database program that I created myself, I created my own
file format and I store information about clients in there. So far, so good,
but when I try to search the content of my file, that's where it becomes
slow....I try to check if a byte is > than 0 in every client's
profile....there are 100 000 clients and the file size is about 200mb.
It goes something like this....
Dim objFile As New System.IO.FileStream("Clients.pcf", IO.FileMode.Open)
For i = 0 To 99999
If Results(i) Then
objFile.Position = (Jump * i) + position
If objFile.ReadByte() > 0 Then
Results(i) = False
End If
End If
Next
Results() is an array of Bool and is used to indicate if the client matches
what I'm looking for. It is used several times by different Subs and passed
as an argument.
Jump indicates the length of each client's profile in bytes.
Position indicates where the information is located within the client's
profile.
My computer is old (1gHz), but still, a task like that takes almost 30
seconds...I found out that this line slows everything down: objFile.Position
= (Jump * i) + position, but a multiplication is not supposed to take that
long (I've tried it separately) and if I click a second time on the button
that handles that event, it takes less that a second to get my results....
I've even looked at the CPU usage and it goes up only for the
second....what's happening? Is VB copying my file somewhere?
I must say that I'm more that confused right now....I'm sorry if this is a
long post, but it's a pretty complex situation and I would appreciate every
suggestion.