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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 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