Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
Medium Priority
?
365 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 2000 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

636 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