Question

This program http://www.fourmilab.ch/random/ scans an entire file to determine it's information density (aka entropy/randomness).

I want to edit it to scan only the first .01 MB of the file rather than the whole thing in order to speed up scan times (the network share I need to scan is 2TB).

The source is included in the download so it should be easy to do; I'm just not sure how to get started.

Any ideas?

Was it helpful?

Solution

A quick look at the code in ent.c, shows a while statement on line 181. This line does an fgetc from the file pointed to by fp. In order to get this to work correctly, you would just add a counter to the statement. Something along the lines of

while ((my_count++ < MAX_COUNT) && ((oc = fgetc(fp)) != EOF))

where my_count is an int (or long - depending on how big you really want) and MAX_COUNT for you would be 100000. Be sure to initialize my_count to 0.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top