SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 05/07/2016, 11:13 PM   #1
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,736
Reputation: 789
Default dini2.inc - Improved dini file processor with amazing performance (aka. gini)!

dini2.inc
Updated: v3.1 (10 March, 201
Improved version of "dini.inc" with high performance and same syntax!

INI is mostly used for initializing data to your server. But i have seen many gamemodes/filterscripts still use this old library which is very slow/inefficient in today's time, so i though of making an improved version.

How this works?
Well it works with arrays. The files' data is read once when you use any "Set" function of dini. A timer starts which will free the memory of that file later after 'n' milliseconds. So unlike original dini, this one don't open and close a file everytime we use a Set/Get function. It works exactly like SII but with the ability to operate multiple files at a time.

Benchmark
Quote:
* Dini2.inc
Writing 100 files with 64 fields, 3 times takes: 333 ms
Reading 100 files with 64 fields, 3 times takes: 132 ms


* Dini.inc (old version)
Writing 100 files with 64 fields, 3 times takes: 36485 ms
Reading 100 files with 64 fields, 3 times takes: 1835 ms
Its like saving 100 players data 3 times all at once (64 fields each file)!

Benchmark Source-Code
You can use this code to perform tests with other INI processors to compare results!

How to compare results with original Dini.inc and Dini2.inc?
First compile the script with "#include <Dini2.inc>" and then run the samp-server.exe.
Second test, replace "#include <Dini2.inc>" to "#include <Dini.inc>" and compile. Run samp-server.exe.

You have result for both. Dini is way way slower than new one. Don't run test on 500 files for Dini.inc, it will hang up or you have to wait for hours to get results lol!

PHP Code:
#include <a_samp>
#include <Dini2>

main() {
    const 
ITERATIONS 3;
    const 
NUM_FILES 100;
    const 
NUM_FIELDS 64;
    
    new 
se;

    new 
fileName[54];
    new 
fieldName[64];

    
// START
    
GetTickCount();
    
//

    
for (new aITERATIONSa++) {
        for (new 
bNUM_FILESb++) {
            
format(fileNamesizeof fileName"file_%i.ini"b);
            
#if !defined dini2_included
            
dini_Create(fileName);
            
#endif
            
            
for (new cNUM_FIELDSc++) {
                
format(fieldNamesizeof fieldName"field_%i"c);
                
dini_Set(fileNamefieldName"value");
            }
        }
    }

    
#if defined dini2_included
    
for (new aNUM_FILESa++) {
        
format(fileNamesizeof fileName"file_%i.ini"a);
        
dini_Timeout(fileName);
    }
    
#endif

    //
    
GetTickCount();
    
printf("Writing %i files with %i fields, %i times takes: %i ms"NUM_FILESNUM_FIELDSITERATIONS, (s));
    
// END



    // START
    
GetTickCount();
    
//

    
for (new aITERATIONSa++) {
        for (new 
bNUM_FILESb++) {
            
format(fileNamesizeof fileName"file_%i.ini"b);
            
#if !defined dini2_included
            
dini_Create(fileName);
            
#endif
            
            
for (new cNUM_FIELDSc++) {
                
format(fieldNamesizeof fieldName"field_%i"c);
                
dini_Get(fileNamefieldName);
            }
        }
    }

    
#if defined dini2_included
    
for (new aNUM_FILESa++) {
        
format(fileNamesizeof fileName"file_%i.ini"a);
        
dini_Timeout(fileName);
    }
    
#endif

    //
    
GetTickCount();
    
printf("Reading %i files with %i fields, %i times takes: %i ms"NUM_FILESNUM_FIELDSITERATIONS, (s));
    
// END



    
for (new aNUM_FILESa++) {
        
format(fileNamesizeof fileName"file_%i.ini"a);
        
dini_Remove(fileName);
    }

Functions
PHP Code:
dini_Exists(const filename[]);
dini_Remove(const filename[]);
dini_Create(const filename[]);
dini_Set(const filename[], const key[], const value[]);
dini_IntSet(const filename[], const key[], value);
dini_FloatSet(const filename[], const key[], Float:value);
dini_BoolSet(const filename[], const key[], bool:value);
dini_Get(const filename[], const key[]);
dini_Int(const filename[], const key[]);
Float:dini_Float(const filename[], const key[]);
bool:dini_Bool(const filename[], const key[]);
dini_Unset(const filename[], const key[]);
dini_Isset(const filename[], const key[]);
DINI_StripNewLine(const string[]);
DINI_fcopytextfile(const filename[], const newfilename[]);

// New function from v1.0+
dini_Timeout(const filename[]);

// New functions from v3.0+
dini_NumKeys(const filename[]);
dini_GetKeyName(const filename[], keyid);

// New function from v3.1+
DINI_frenametextfile(const filename[], const newfilename[]); 
Download
https://github.com/Agneese-Saini/SA-...lude/dini2.inc
__________________

Last edited by Gammix; 12/06/2018 at 03:50 PM.
Gammix is offline   Reply With Quote
Old 06/07/2016, 12:59 AM   #2
Dayvison_
High-roller
 
Dayvison_'s Avatar
 
Join Date: Nov 2013
Posts: 1,318
Reputation: 200
Default Re: gini.inc - Fast multi file processor with "dini's" syntax

Any bench?
I suggest you put suport for sections ^^
Good work ^^
__________________


Dayvison_ is offline   Reply With Quote
Old 06/07/2016, 01:12 AM   #3
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,736
Reputation: 789
Default Re: gini.inc - Fast multi file processor with "dini's" syntax

Quote:
Originally Posted by Day_ View Post
Any bench?
The way this works is pretty different, if you benchmark functions, they will be like "1ms" for 1000 iterations or even more. Because the operation of writing the file is done in a timer which gets executed after defined seconds.

I'll try to make up some by editing the include; probably by using 2ms for timer's interval.

Quote:
Originally Posted by Day_ View Post
I suggest you put suport for sections ^^
What do you mean ?
__________________
Gammix is offline   Reply With Quote
Old 06/07/2016, 01:19 AM   #4
Uberanwar
Gangsta
 
Uberanwar's Avatar
 
Join Date: May 2012
Location: Malaysia
Posts: 817
Reputation: 62
Default Re: gini.inc - Fast multi file processor with "dini's" syntax

Wow Gammix, you've made a lot of contributions to the community! Keep up the good work man.
+rep
Uberanwar is offline   Reply With Quote
Old 06/07/2016, 02:26 AM   #5
ItzShady
Huge Clucker
 
ItzShady's Avatar
 
Join Date: Aug 2014
Location: Egypt
Posts: 210
Reputation: 23
Default Re: gini.inc - Fast multi file processor with "dini's" syntax

Amazing, man. I did a test on my server and found out that GINI is faster than Y_INI and DINI.

Edit: On another script (NGRP), I got some errors. Mind if help ya?
Code:
./includess/commands.pwn(23306) : error 017: undefined symbol "dini_Exists"
./includess/mysql.pwn(5653) : error 017: undefined symbol "dini_Create"
./includess/mysql.pwn(5654) : error 017: undefined symbol "dini_Remove"
./includess/mysql.pwn(5655) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5656) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5657) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5658) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5659) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5660) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5661) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5662) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5663) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5664) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(6) : error 017: undefined symbol "dini_Exists"
./includess/OnPlayerLoad.pwn(8) : error 017: undefined symbol "dini_Create"
./includess/OnPlayerLoad.pwn(9) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(10) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(11) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(12) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(13) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(14) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(15) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(16) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(17) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(18) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(19) : error 017: undefined symbol "dini_IntSet"

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


26 Errors.
ItzShady is offline   Reply With Quote
Old 06/07/2016, 03:02 AM   #6
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,736
Reputation: 789
Default Re: gini.inc - Fast multi file processor with "dini's" syntax

Quote:
Originally Posted by ShadyEG View Post
Amazing, man. I did a test on my server and found out that GINI is faster than Y_INI and DINI.

Edit: On another script (NGRP), I got some errors. Mind if help ya?
Code:
./includess/commands.pwn(23306) : error 017: undefined symbol "dini_Exists"
./includess/mysql.pwn(5653) : error 017: undefined symbol "dini_Create"
./includess/mysql.pwn(5654) : error 017: undefined symbol "dini_Remove"
./includess/mysql.pwn(5655) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5656) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5657) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5658) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5659) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5660) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5661) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5662) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5663) : error 017: undefined symbol "dini_IntSet"
./includess/mysql.pwn(5664) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(6) : error 017: undefined symbol "dini_Exists"
./includess/OnPlayerLoad.pwn(8) : error 017: undefined symbol "dini_Create"
./includess/OnPlayerLoad.pwn(9) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(10) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(11) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(12) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(13) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(14) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(15) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(16) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(17) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(18) : error 017: undefined symbol "dini_IntSet"
./includess/OnPlayerLoad.pwn(19) : error 017: undefined symbol "dini_IntSet"

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


26 Errors.
v1.1.1 creates all DINI functions when INI_CONVERT_DINI is defined. Checkout the thread once again for instructions.
__________________
Gammix is offline   Reply With Quote
Old 06/07/2016, 03:11 AM   #7
ItzShady
Huge Clucker
 
ItzShady's Avatar
 
Join Date: Aug 2014
Location: Egypt
Posts: 210
Reputation: 23
Default Re: gini.inc - Fast multi file processor with "dini's" syntax

Updated again to v1.1.2 due to another bug in the new conversation.
ItzShady is offline   Reply With Quote
Old 06/07/2016, 03:36 AM   #8
WhiteGhost
Guest
 
Posts: n/a
Default Re: gini.inc - Fast multi file processor with "dini's" syntax

Quote:
Originally Posted by Uberanwar View Post
Wow Gammix, you've made a lot of contributions to the community! Keep up the good work man.
+rep
Ikr imagine if he were to have a server it would be awesome.
Anyways GoodJob You got my rep even before this.
  Reply With Quote
Old 06/07/2016, 03:54 AM   #9
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,736
Reputation: 789
Default Re: gini.inc - Fast multi file processor with "dini's" syntax

Thanks all.

I realized most of the scripts use INI as a database and taking that in mind, we cannot execute so many timers at once (max is maybe 30). So in next update, i'll use on global timer to run and work on tick counts.
__________________
Gammix is offline   Reply With Quote
Old 06/07/2016, 04:11 AM   #10
SystemX
Big Clucker
 
SystemX's Avatar
 
Join Date: Nov 2015
Location: !ncredible !ndia
Posts: 73
Reputation: 17
Default Re: gini.inc - Fast multi file processor with "dini's" syntax

Amazing as always budd'
+repp
SystemX is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] [I-ZCMD]Improved ZCMD - Fastest Command Processor Yashas Includes 99 23/07/2017 04:23 PM
[Off] Dini2? yurin Português/Portuguese 5 27/11/2016 02:09 AM
[Include] eXtended INI Processor - Fast & Feature Rich INI Processor Yashas Includes 28 01/09/2015 07:45 PM
[INC+FS] Aero File Processor by Luby * Updated! luby Filterscripts 15 14/05/2009 01:07 PM


All times are GMT. The time now is 05:26 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.