help with fscanf
View Single Post
03-04-2009, 06:25 PM
Join Date: Feb 2009
Location: New York
Originally Posted by
The value 11695 isn't the number of matches persay. It's the number of rows that the script had to search through until reaching the row (row #11696) which contains only "1644592". This is not a viable test of the script since the file is generated randomly and the speed of execution relies on the position of the matching line (if at all) in the file.
With the results shown above by Sakakuchi, it shows that 11696 lines were examined in 124ms (each line took approx 0.01ms). The loop stops when the line is found because the fscanf call returns NULL (if 1644592 is the entire line, it can't pull back any string value which you asked for in the formatting string). This, as far as I understand, is a misuse of fscanf.
My own fluffing of the test so that a match is made on line 11696 produced a result of 22.1ms (0.002ms per line). These results cannot be relied on for anything useful (except perhaps the per-line execution speed) because they only look through 1.17% of the file! Try looking for "1644592blahblahblah%s\n" instead of "1644592%s\n" and paste those results since that will force the script to look through the entire file (and fail to find a match).
HAHAHA you're crazy!! You know TOO MUCH!!!
View Public Profile
Send a private message to allworknoplay
Find More Posts by allworknoplay