I have the following function
for(i = 0; i < lines; i++)
fgets(i[*compare], 36, fp);
It populates the “pointer to an array of X chars of an array of X chars with the string from the file pointer stream fp. The variable lines is the number of lines the file has(precomputed).
I wish to calculate the reading speed of the fgets operation. However I am unsure of how to do this, nor the “formula”
Use
clock_gettimeto obtain some time, and wrap it around fgets. Then appropriately subtractafromband you have the time it took to execute fgets (and one clock_gettime call).36 chars is not a lot, so it’ll be over faster than can be noticably measured. (But then again I hear Linus’s words (about git), “well maybe on Windows maybe you can [measure it]”…) Anyhow, you then now that (at most) this many chars were transferred in the found delta time.