Define_Type overhead
Spire_Jeff
Formerly Caffeinated Programmer
Does anyone know how much overhead is involved with creating structures? The reason I ask is that I currently use 4 different structures to house a bunch of configuration information. I am finding that I need to occasionally add items to the structure. The problem arises in that I am currently using the variable_to_string function to store the configuration to disk and I don't think I can retrieve the data if I change the structure. (I cannot use variable_to_xml because of flaws in the function)
The way I am trying to solve this is by using a version file that indicates what version the data was saved as. I then use that to read the data into a stack_var of the correct version type and then populate the current structure accordingly. Right now, I only have 2 or 3 versions of each structure, so I doubt that the extra structure definitions will cause problems, but I wanted to make sure. I am also thinking about the future and trying to decide how many previous versions I will let the program automatically convert.
I can always write a separate program that simply goes through and updates the files, but I kind of like the ability to restore backup files on the fly as long as they are within a couple versions of the current.
Jeff
The way I am trying to solve this is by using a version file that indicates what version the data was saved as. I then use that to read the data into a stack_var of the correct version type and then populate the current structure accordingly. Right now, I only have 2 or 3 versions of each structure, so I doubt that the extra structure definitions will cause problems, but I wanted to make sure. I am also thinking about the future and trying to decide how many previous versions I will let the program automatically convert.
I can always write a separate program that simply goes through and updates the files, but I kind of like the ability to restore backup files on the fly as long as they are within a couple versions of the current.
Jeff
Comments
-
My guess would be when you define a structure the metadata that contains the names of each member and size of each is stored somewhere in memory, and the memory space for each variable using the structure only contains the actual data. So, the actual overhead for variable storage wouldn't be any bigger than the data itself ... the metadata for the storage conventions only appears once and is relatively negligible.
As for your other issue, I usually find it best to break the structures into a more generic form. My preference is to feed the data out into a CVS file, then read it back in when the module loads. Then you could put your version number right in the first CVS record, and interpret it accordingly as it's read ... when you write the data out again, it can automatically update the version accordingly. -
Spire_Jeff wrote: »The problem arises in that I am currently using the variable_to_string function to store the configuration to disk and I don't think I can retrieve the data if I change the structure. (I cannot use variable_to_xml because of flaws in the function)
I would not use a binary data store for the reason you mentioned. Simple text is the most flexible if you come up with your own scheme, depending on the data. I have abandoned structures except in limited cases and use only arrays now. Until they change things so that structures can be passed to modules and functions I will use arrays.
Paul
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums