473,396 Members | 1,689 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,396 software developers and data experts.

Really slow filestream

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.
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.
Dec 12 '07 #1
1 1599
Killer42
8,435 Expert 8TB
It's not the multiplication that would be taking the time, but repositioning the file pointer.

A couple of thoughts come to mind.
  • If you can spare the RAM, you might save heaps of time by loading the entire file into an array.
  • I think you'll find that the filestream is designed for flexibility, not speed. You can probably improve performance considerably by using good old-fashioned Binary mode. That is...
    Open "MyFile" For Binary Access Read Write Lock Write As #1
    Positioning is very quick in binary mode.
Dec 13 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Tom | last post by:
I am working with the this object as oppose to the StreamReader object becuase I need to access a file (to find the contents) while an external application is updating the file. When I was...
13
by: Stuart | last post by:
I have converted a VB6 app to VB.NET. It's function is to generate reports from a Random Access file but the .NET version is pathetically slow compared to the VB6 version. I think I need to to...
4
by: Marty | last post by:
Hi, I use a streamwriter object to write in a text files hundreds time per seconds. When my file get very big, can this process is subject to slow down my application? Here is part of my...
7
by: Nathan Sokalski | last post by:
I am having a problem saving an image with the same name it originally had. I have two similar versions of my code, one in which I close the FileStream used to open the original image before saving,...
5
by: Eric Cadwell | last post by:
Is there a faster way to write the last 100K of a large file? This code takes almost two minutes to run on my machine. int buffer = 100000; int length = 2000000000; string file =...
5
by: rony_16 | last post by:
Hi, I have a problem downloading a file . after i connect to the website and get the stream , i treing to write the file on the HD. public void SaveStreamToFile(string filePath, Stream stream) {...
5
by: fcharby | last post by:
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...
8
by: =?Utf-8?B?RnJhbms=?= | last post by:
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...
10
by: cellus205 | last post by:
Hows it going everyone. Im still pretty new to vb .net, and am having a little trouble. I am loading a tab delimited txt file into an access database, and parsing the text to extract some of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.