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
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
359 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

828 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