Re: $10,000 Question ~ "The foo variable"
Hi Cal,
Just too funny!
As it turns out in reality, no. But 200 times faster than tbl.field_name_get()? Or did you mean the loop version? a5_get_fieldnames() is an Xbasic wrapper that will return set fields as well as table fields, so you have a function and some decision code as overhead.
Faster is the direct function (actually a method to be 100% clear) table.external_field_name_get(). If the table referenced is already open, it runs about 10 times faster.
Using something like table_pointer.field_name_get() is even just a bit faster than table.external_field_name_get(). Obviously you have to open the table 1st, but when you include that and a table.close(), it is still faster than table.external_field_name_get(). If the table was already open for both, it still wins by a hair.
See comparative execute time to run code for 3 types below with and without table initially open
So in conclusion, based upon my timings and analysis, no it is not simpler if you already have the table open, and is faster even if you have to open the table (albeit with slightly more code).
These were all tested in V8, specific versions could vary a bit, but not likely.
Hi Cal,
Just too funny!
Originally posted by CALocklin
View Post
Faster is the direct function (actually a method to be 100% clear) table.external_field_name_get(). If the table referenced is already open, it runs about 10 times faster.
Using something like table_pointer.field_name_get() is even just a bit faster than table.external_field_name_get(). Obviously you have to open the table 1st, but when you include that and a table.close(), it is still faster than table.external_field_name_get(). If the table was already open for both, it still wins by a hair.
See comparative execute time to run code for 3 types below with and without table initially open
Code:
' Init code dim tablename as c tablename="your_tablename" dim x as c ' Table is not open prior to running code x=a5_get_fieldnames(tablename) ' .00712 x=table.external_field_name_get(tablename) ' .00648 ' .00666 time for the next 4 lines dim tbl as p tbl=table.open(tablename) x=tbl.field_name_get() tbl.close() ' versus below if table is open already dim tbl as p tbl=table.open(tablename) x=a5_get_fieldnames(tablename) ' .00123 x=table.external_field_name_get(tablename) ' .000605 x=tbl.field_name_get() ' .000441 tbl.close()
These were all tested in V8, specific versions could vary a bit, but not likely.
Comment