Solved

How to rework my C# console application code so that it writes out records on a more timely basis?

Posted on 2014-01-27
1
355 Views
Last Modified: 2014-02-03
I am writing a C# console application using VS2010 that reads a check image file comprised of a combination of binary and text data and writes out 3 files.

The application writes out records very slowly. I was wondering if you could suggest alternate code to make it run faster. It only writes out about 2 records per minute to the file with the file extension "ard.out".

My code is attached.
BankCheckImage.txt
0
Comment
Question by:zimmer9
1 Comment
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 500 total points
ID: 39813069
Not sure how significant this is, but you seem to do a LOT of needless skipping...

In the

for (int i = 0; i < bytes.Length; i++)

loop, you skip 0 bytes at
var data = bytes.Skip(i).Take(anchor1.Length);
the first time, then 1, then 2....etc.  If bytes.Length is large, this could involve a LOT of repeated skipping, when you could have done (initially set restBytes = bytes)

var data = restBytes.Take(anchor1.Length);

....
....
....
stuff
....

restBytes = restBytes.Skip(1);

where you never have to skip more than one item per loop.

There are other instances in your code of the same construct.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now