[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

CRCs - Calculating them quickly for a File

Posted on 1997-06-20
4
Medium Priority
?
378 Views
Last Modified: 2010-04-04

I have written some code to Calculate the CRCs of a bunch of files.

The trouble is that I have done all the CRC calculations using binary digits held in strings so it is VERY S.L.O.W. !!

I did it this way, because it makes the code so easy to understand - but the draw back is that it is slow !

I kind of started to convert my code over to using Integers and doing everything using Bitwise operators (SHL, XOR, etc) but (after my very early benchmarks) I didn't get the speed improvement I was desperate for.

The trouble is that my CRC code needs to be finished very quickly, so I have sort of run out of time.

I need some very fast code to calculate and return the CRC for a file, which I can then call for all files in my list.

I am not too fusy about whether 16 or 32 bit CRCs are calculated, as long as the code works under 16 and 32 bit Delphi and is fast.

Can anybody help ?

I have assigned a lot of points to this question to try and get some good quick help on this.

TIA
Moose
0
Comment
Question by:moose032797
  • 2
4 Comments
 
LVL 3

Expert Comment

by:mheacock
ID: 1337332
It might be slow because you are reading from the disk file
often...

Try reading the entire file into an array of bytes...you can
do all this with two commands...a GetMem and then a read...
can't rmember what the read command is...I do remember seeing
it help...perhaps a stream??

Anyhow, if you do all your calculations in memory, then it
should be dramatically faster...
0
 

Author Comment

by:moose032797
ID: 1337333
No, I am reading 4 KB buffer at once, so it is definetely how I have done the calculations.

I have now converted my STRING based calculations to Long Integers - the problem now is + / - flipping of numbers.
For me, a 1 in the leftmost bit does not indicate a negative number - unfortunately, I don't know how to get around this under Delphi - as there are no positive only numbers.
So, the CRC results are wrong.

Any ideas anyone ?

Anybody have a good fast algorithm for CRCs ?

Hope somebody can help.

Moose
0
 
LVL 3

Accepted Solution

by:
sperling earned 300 total points
ID: 1337334
Hope you'll accept this URL as an answer. Got quite a few CRC units.

http://www.pcorner.com/tpc/old/35-101.html

Regards,

Erik.
0
 

Author Comment

by:moose032797
ID: 1337335
Thanks Eric - the link you provided was great.

It took no time at all to take one of these Turbo pascal programs and get it working under Delphi - also improved it as well.

Code works great and is fast !!

Thanks for your help - again !!

Moose
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

834 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