20.01.2014, 23:12
Ah it's good to be back making my first new topic!
Intro
Anyway, for the past year I've been working on a gamemode script and from the start I wanted a robust, speedy and flexible method of saving. INI files are flexible but not speedy, SQL is sort of flexible but not amazingly fast and Pawn line limit is a bastard for queries.
So I decided on using the fblock functions, I've loved these since I started working with files but never really found a use for them until around 2 years ago. There's a lack of love for them on the forums! I will write a nice tutorial/guide at some point. But until then, there's a decent amount of information in this topic. (My guide will focus more on how to use the functions in real situations such as saving player data and other things)
Testing
I've been testing the encoded vs binary methods recently and I am interested in sharing these tests and getting some feedback from the more experienced coders who I see around the scripting discussion area.
So far, I have two tests. The first is a basic write and read of 4mb of data (1024 32b cells or 4096 bytes) and the second is a more practical test which writes the encoded data with delimiters then uses sscanf to extract the data afterwards (a common practice)
Code
Here is the test code and results from my windows machine:
https://gist.github.com/Southclaw/8482426
Run it as a filterscript, preferably on a completely blank gamemode for obvious reasons.
"What the hell is y_speedtest?" I hear you ask. Sorry that's my own include name because Y_Less only released the code as a snippet! You can grab that from over here. It's not any part of YSI, just a standalone benchmarking include that really should have it's own topic because it's so useful *stares at Y_Less*.
Notes
Q: Why are the fopen and fclose functions included in the benchmark?
A: Because I didn't want to let the file size grow, I am unsure whether or not that affects performance. And generally, fopen/fwrite/fclose is all one process (fread is a different story, but the tests don't deal with multi-line files at the moment)
Q: What about SQL?
A: I do plan to add an SQL test that deals with the same method of data. I will do this on the third test I have planned, which deals with a much more practical implementation (saving a player's password hash, IP, and some stats such as cash).
Intro
Anyway, for the past year I've been working on a gamemode script and from the start I wanted a robust, speedy and flexible method of saving. INI files are flexible but not speedy, SQL is sort of flexible but not amazingly fast and Pawn line limit is a bastard for queries.
So I decided on using the fblock functions, I've loved these since I started working with files but never really found a use for them until around 2 years ago. There's a lack of love for them on the forums! I will write a nice tutorial/guide at some point. But until then, there's a decent amount of information in this topic. (My guide will focus more on how to use the functions in real situations such as saving player data and other things)
Testing
I've been testing the encoded vs binary methods recently and I am interested in sharing these tests and getting some feedback from the more experienced coders who I see around the scripting discussion area.
So far, I have two tests. The first is a basic write and read of 4mb of data (1024 32b cells or 4096 bytes) and the second is a more practical test which writes the encoded data with delimiters then uses sscanf to extract the data afterwards (a common practice)
Code
Here is the test code and results from my windows machine:
https://gist.github.com/Southclaw/8482426
Run it as a filterscript, preferably on a completely blank gamemode for obvious reasons.
"What the hell is y_speedtest?" I hear you ask. Sorry that's my own include name because Y_Less only released the code as a snippet! You can grab that from over here. It's not any part of YSI, just a standalone benchmarking include that really should have it's own topic because it's so useful *stares at Y_Less*.
Notes
Q: Why are the fopen and fclose functions included in the benchmark?
A: Because I didn't want to let the file size grow, I am unsure whether or not that affects performance. And generally, fopen/fwrite/fclose is all one process (fread is a different story, but the tests don't deal with multi-line files at the moment)
Q: What about SQL?
A: I do plan to add an SQL test that deals with the same method of data. I will do this on the third test I have planned, which deals with a much more practical implementation (saving a player's password hash, IP, and some stats such as cash).