473,398 Members | 2,403 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,398 software developers and data experts.

App Performance help

Hi,
I am developing an app that will unzip several zip files and append the
contents of the zip files to one text file. The zip files contains one text
file with a standard format but the size of the file will be an average of
100k to 300k with at least 7000 rows.

Could I use a simple string (Dim s as string)? So first I would unzip a
file, read its contents, store it in the string then unzip the second, append
it's contents to the same string ........after all the files are unzipped I
then write the contents of the string to a text file. Is that the proper way?

Thanks
Aug 16 '05 #1
6 1267
It would work for a small set of files. Problem is that your plan is
terrible on memory. Strings are immutable in .Net which means that you
create a string for a file, create a string for another file, then throw
them both away as soon as you have a string for the two files together.

If you are simply appending, then use a textreader and textwriter.

Psuedocode
open the source zip
get a list of contained files
open the destination file for append
for each file in the zip
unzip the file (into memory?) I don't know what library you are
using
open the input file stream
while not eof(input file stream)
read a block of text (say, about 20K?)
write the block of text to the destination file
end while
close unzipped file (and clean up, if necessary)
next file
close destination file
This will scale to situations where the zip contains large individual files
as well as when the zip contains large numbers of files.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:CC**********************************@microsof t.com...
Hi,
I am developing an app that will unzip several zip files and append the
contents of the zip files to one text file. The zip files contains one
text
file with a standard format but the size of the file will be an average of
100k to 300k with at least 7000 rows.

Could I use a simple string (Dim s as string)? So first I would unzip a
file, read its contents, store it in the string then unzip the second,
append
it's contents to the same string ........after all the files are unzipped
I
then write the contents of the string to a text file. Is that the proper
way?

Thanks

Aug 16 '05 #2
Each of my zip files has a single file and the file is about 200k with about
7000 rows. I'll have to loop abou 10 zip files. Should I unzip to memory
orunzip the file to a folder then read the file and append each file to the
new file created?

"Nick Malik [Microsoft]" wrote:
It would work for a small set of files. Problem is that your plan is
terrible on memory. Strings are immutable in .Net which means that you
create a string for a file, create a string for another file, then throw
them both away as soon as you have a string for the two files together.

If you are simply appending, then use a textreader and textwriter.

Psuedocode
open the source zip
get a list of contained files
open the destination file for append
for each file in the zip
unzip the file (into memory?) I don't know what library you are
using
open the input file stream
while not eof(input file stream)
read a block of text (say, about 20K?)
write the block of text to the destination file
end while
close unzipped file (and clean up, if necessary)
next file
close destination file
This will scale to situations where the zip contains large individual files
as well as when the zip contains large numbers of files.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:CC**********************************@microsof t.com...
Hi,
I am developing an app that will unzip several zip files and append the
contents of the zip files to one text file. The zip files contains one
text
file with a standard format but the size of the file will be an average of
100k to 300k with at least 7000 rows.

Could I use a simple string (Dim s as string)? So first I would unzip a
file, read its contents, store it in the string then unzip the second,
append
it's contents to the same string ........after all the files are unzipped
I
then write the contents of the string to a text file. Is that the proper
way?

Thanks


Aug 16 '05 #3
Chris,

For your problem is the stringbuilder, be aware that you have to set a
reference to System.Text to use it.

http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor
Aug 16 '05 #4
Like I said, I don't know what unzip library you are using. Look into the
code in the library to see which is better at handling memory. In general,
you will get more performance by keeping things in memory, but you may get
better memory management by throwing things to disk.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:37**********************************@microsof t.com...
Each of my zip files has a single file and the file is about 200k with
about
7000 rows. I'll have to loop abou 10 zip files. Should I unzip to memory
orunzip the file to a folder then read the file and append each file to
the
new file created?

"Nick Malik [Microsoft]" wrote:
It would work for a small set of files. Problem is that your plan is
terrible on memory. Strings are immutable in .Net which means that you
create a string for a file, create a string for another file, then throw
them both away as soon as you have a string for the two files together.

If you are simply appending, then use a textreader and textwriter.

Psuedocode
open the source zip
get a list of contained files
open the destination file for append
for each file in the zip
unzip the file (into memory?) I don't know what library you are
using
open the input file stream
while not eof(input file stream)
read a block of text (say, about 20K?)
write the block of text to the destination file
end while
close unzipped file (and clean up, if necessary)
next file
close destination file
This will scale to situations where the zip contains large individual
files
as well as when the zip contains large numbers of files.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:CC**********************************@microsof t.com...
> Hi,
> I am developing an app that will unzip several zip files and append the
> contents of the zip files to one text file. The zip files contains one
> text
> file with a standard format but the size of the file will be an average
> of
> 100k to 300k with at least 7000 rows.
>
> Could I use a simple string (Dim s as string)? So first I would unzip a
> file, read its contents, store it in the string then unzip the second,
> append
> it's contents to the same string ........after all the files are
> unzipped
> I
> then write the contents of the string to a text file. Is that the
> proper
> way?
>
> Thanks


Aug 16 '05 #5
Hi,
How do I destroy a stringbuilder after the data is sent to a text file.
Should I use

sb=nothing

Thanks

"Cor Ligthert [MVP]" wrote:
Chris,

For your problem is the stringbuilder, be aware that you have to set a
reference to System.Text to use it.

http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor

Aug 17 '05 #6
Chris,

There are only very few cases in managed languages where you have to set an
object to nothing or whatever like that.

Most of those is where you have placed objects globaly, otherwise they will
go out of scoped and automaticly be released.

I hope this helps,

Cor
Aug 18 '05 #7

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

Similar topics

25
by: Brian Patterson | last post by:
I have noticed in the book of words that hasattr works by calling getattr and raising an exception if no such attribute exists. If I need the value in any case, am I better off using getattr...
5
by: rc | last post by:
Hi We have a SQL server on Win2k. the physical size of the db is about 40G and the main table has approx 65m rows in it. At the moment the entire database is on one data file. The entire server...
12
by: serge | last post by:
I have an SP that is big, huge, 700-800 lines. I am not an expert but I need to figure out every possible way that I can improve the performance speed of this SP. In the next couple of weeks I...
6
by: teedilo | last post by:
We have an application with a SQL Server 2000 back end that is fairly database intensive -- lots of fairly frequent queries, inserts, updates -- the gamut. The application does not make use of...
7
by: Randell D. | last post by:
Folks, I have a Javascript performance question that I might have problems explaining... In PHP, better performance can be obtained dealing directly with a variable, as opposed to an element...
4
by: Martin | last post by:
I am using graphics as backgrounds for forms,buttons,labels etc. The question is: is it faster to load all graphics from files on app start or to use it embeded (places in editor during design)....
5
by: Markus Ernst | last post by:
Hello A class that composes the output of shop-related data gets some info from the main shop class. Now I wonder whether it is faster to store the info in the output class or get it from the...
1
by: jvn | last post by:
I am experiencing a particular problem with performance counters. I have created a set of classes, that uses System.Diagnostics.PerformanceCounter to increment custom performance counters (using...
4
by: skotapal | last post by:
Hello I manage a web based VB .net application. This application has 3 components: 1. Webapp (this calls the executibles) 2. database 3. business logic is contained in individual exe...
0
by: Eric Davidson | last post by:
As part of my thesis for my MSc Course with the Open University UK, I need to collect various performance statics for IBM's DB2 database on Windows. To this end I have developed a performance...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.