Array benchmark
Jun 3, 2012 14:17:07 GMT 1
Post by Deleted on Jun 3, 2012 14:17:07 GMT 1
I've found another "interesting" topic on BP.org: forum.basicprogramming.org/index.php?topic=2608.msg18990#msg18990. JRS says that BaCon takes more than an hour and a half to complete that task, so I've found wordcitiespop.txt file ( www.maxmind.com/download/worldcities/ ) that is 144 MB big and written my own program:
The result is 22217713 (more than 22 millions) and, on my computer, it takes BaCon... 11 sec. to complete the task.
EDIT: Here is a version that uses REDIME statement to change a final size of the main array:
This one is a bit slower. It takes 18 sec. to complete the task.
Peter, please post my examples on BP.org (I was banned from that forum) to show everybody that what JRS says is simply not true (he just doesn't know how to use BaCon). You could also write much faster example using more advanced techniques, but I don't think there is a point to waste your time for it.
Regards!
OPTION BASE 1
GLOBAL all$[100000000] TYPE STRING
OPEN "worldcitiespop.txt" FOR READING AS ksiazka
counter = 0
WHILE NOT(ENDFILE (ksiazka)) DO
READLN akapit$ FROM ksiazka
SPLIT akapit$ BY "," TO slowa$ SIZE siz
FOR x = 1 TO siz
all$[counter + 1] = slowa$[x]
NEXT X
counter = counter + siz
WEND
CLOSE FILE ksiazka
PRINT counter
The result is 22217713 (more than 22 millions) and, on my computer, it takes BaCon... 11 sec. to complete the task.
EDIT: Here is a version that uses REDIME statement to change a final size of the main array:
OPTION BASE 1
GLOBAL all$ TYPE STRING ARRAY 100000000
OPEN "worldcitiespop.txt" FOR READING AS ksiazka
counter = 0
WHILE NOT(ENDFILE (ksiazka)) DO
READLN akapit$ FROM ksiazka
SPLIT akapit$ BY "," TO slowa$ SIZE siz
FOR x = 1 TO siz
all$[counter + 1] = slowa$[x]
NEXT X
counter = counter + siz
WEND
CLOSE FILE ksiazka
PRINT counter
REDIM all$ TO counter
This one is a bit slower. It takes 18 sec. to complete the task.
Peter, please post my examples on BP.org (I was banned from that forum) to show everybody that what JRS says is simply not true (he just doesn't know how to use BaCon). You could also write much faster example using more advanced techniques, but I don't think there is a point to waste your time for it.
Regards!