D
dvestal
Two scenarios:
1) I have a lot of text, and need to write it to a file on a network
drive. What's the absolute fastest way to do that? Currently, I
write 1 line at a time using StreamWriter.Write, and I switch to a new
file after every 50K lines written. By the time this completes, I've
written some 235 files, and 12 minutes have elapsed.
I've tried such things as using a StringBuilder to create the entire
contents of a single file, then writing it all at once, and splitting
files into 500K lines each instead. Each of these make the process
longer. What's the fastest way to dump text into a file?
If it helps understand the context in which the problem occurs, the
text is data for a bulk SQL insert.
2) What is the absolute fastest way to add rows to a DataTable? I
have a compressed file containing a serialized version of data rows.
To parse the file, I open it using the .NET stream-based compression,
read it 1 line at a time, and insert each line into a DataTable. The
vast majority of time is spent calling DataTable.Rows.Add(); it dwarfs
every other step. Any recommendations on how to speed this up?
1) I have a lot of text, and need to write it to a file on a network
drive. What's the absolute fastest way to do that? Currently, I
write 1 line at a time using StreamWriter.Write, and I switch to a new
file after every 50K lines written. By the time this completes, I've
written some 235 files, and 12 minutes have elapsed.
I've tried such things as using a StringBuilder to create the entire
contents of a single file, then writing it all at once, and splitting
files into 500K lines each instead. Each of these make the process
longer. What's the fastest way to dump text into a file?
If it helps understand the context in which the problem occurs, the
text is data for a bulk SQL insert.
2) What is the absolute fastest way to add rows to a DataTable? I
have a compressed file containing a serialized version of data rows.
To parse the file, I open it using the .NET stream-based compression,
read it 1 line at a time, and insert each line into a DataTable. The
vast majority of time is spent calling DataTable.Rows.Add(); it dwarfs
every other step. Any recommendations on how to speed this up?