[Include] dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)!
#1

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
Reply


Messages In This Thread
dini2.inc - Improved dini file processor with amazing performance (aka. gini)! - by Gammix - 05.07.2016, 23:13
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Dayvison_ - 06.07.2016, 00:59
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 06.07.2016, 01:12
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Uberanwar - 06.07.2016, 01:19
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Shady - 06.07.2016, 02:26
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 06.07.2016, 03:02
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Shady - 06.07.2016, 03:11
Re: gini.inc - Fast multi file processor with "dini's" syntax - by WhiteGhost - 06.07.2016, 03:36
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 06.07.2016, 03:54
Re: gini.inc - Fast multi file processor with "dini's" syntax - by SystemX - 06.07.2016, 04:11
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Ritzy2K - 06.07.2016, 05:04
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Yashas - 06.07.2016, 12:56
Re: gini.inc - Fast multi file processor with "dini's" syntax - by GhostHacker - 06.07.2016, 13:15
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 08.07.2016, 00:43
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Kar - 08.07.2016, 04:54
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 08.07.2016, 05:20
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Romz - 08.07.2016, 06:37
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 08.07.2016, 14:43
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 08.07.2016, 17:35
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Dalayma - 09.07.2016, 17:01
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 09.07.2016, 17:23
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Dalayma - 09.07.2016, 20:53
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 09.07.2016, 21:01
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Yashas - 15.07.2016, 17:30
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 15.07.2016, 19:22
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Sioux - 21.07.2016, 18:57
Re: gini.inc - Fast multi file processor with "dini's" syntax - by iKarim - 21.07.2016, 19:10
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Dalayma - 26.07.2016, 16:02
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 27.07.2016, 04:39
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 14.11.2016, 14:56
Re: gini.inc - Fast multi file processor with "dini's" syntax - by 14_KaPaT - 14.11.2016, 18:17
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 14.11.2016, 18:30
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 15.11.2016, 22:35
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Vadyanga - 29.11.2016, 12:47
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Vadyanga - 29.11.2016, 12:49
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Zorono - 02.12.2016, 12:08
Re: gini.inc - Fast multi file processor with "dini's" syntax - by JokeyL - 13.12.2016, 17:36
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 14.12.2016, 13:22
Re: gini.inc - Fast multi file processor with "dini's" syntax - by JokeyL - 14.12.2016, 17:06
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 15.12.2016, 03:55
Re: gini.inc - Fast multi file processor with "dini's" syntax - by JokeyL - 17.12.2016, 20:18
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 18.12.2016, 03:25
Re: gini.inc - Fast multi file processor with "dini's" syntax - by JokeyL - 18.12.2016, 11:44
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 18.12.2016, 12:01
Re: gini.inc - Fast multi file processor with "dini's" syntax - by JokeyL - 18.12.2016, 12:14
Re: gini.inc - Fast multi file processor with "dini's" syntax - by JokeyL - 18.12.2016, 12:29
Re: gini.inc - Fast multi file processor with "dini's" syntax - by Gammix - 18.12.2016, 12:42
Re: gini.inc - Fast multi file processor with "dini's" syntax - by JokeyL - 18.12.2016, 12:57
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by JokeyL - 18.12.2016, 13:16
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 18.12.2016, 13:32
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 28.12.2016, 13:29
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by JokeyL - 28.12.2016, 16:38
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 28.12.2016, 17:12
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by CantBeJohn - 28.12.2016, 19:30
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 28.12.2016, 19:55
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by CantBeJohn - 28.12.2016, 20:16
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by JokeyL - 29.12.2016, 12:45
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by JokeyL - 08.01.2017, 15:59
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by JokeyL - 11.01.2017, 18:06
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 11.01.2017, 19:02
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by JokeyL - 12.01.2017, 17:41
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by czop1223 - 14.01.2017, 02:59
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by JokeyL - 14.01.2017, 20:46
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 16.01.2017, 14:06
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Romz - 16.01.2017, 14:14
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 16.01.2017, 14:24
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by JokeyL - 16.01.2017, 17:54
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by JokeyL - 20.01.2017, 07:29
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 22.01.2017, 14:18
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Lordzy - 22.01.2017, 15:04
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 22.01.2017, 16:16
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Lordzy - 22.01.2017, 16:58
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by JokeyL - 22.01.2017, 21:29
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 22.01.2017, 22:33
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by JokeyL - 23.01.2017, 19:31
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by OneDay - 19.05.2017, 12:42
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 19.05.2017, 12:51
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by JokeyL - 23.05.2017, 17:38
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by asri - 26.05.2017, 03:58
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by iLearner - 07.06.2017, 06:10
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 12.06.2017, 13:31
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by JokeyL - 12.06.2017, 14:14
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 12.06.2017, 16:29
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by JokeyL - 12.06.2017, 21:44
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by iLearner - 12.06.2017, 22:07
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 13.06.2017, 04:32
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Dalayma - 13.06.2017, 05:41
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by JokeyL - 13.06.2017, 10:50
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Yousha - 06.07.2017, 17:40
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by iLearner - 21.08.2017, 21:42
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Belengher - 05.10.2017, 14:51
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 05.10.2017, 16:15
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by JokeyL - 05.10.2017, 16:39
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 06.10.2017, 23:42
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by JokeyL - 08.10.2017, 21:48
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Marllun - 21.11.2017, 03:04
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Usmanmemon - 21.11.2017, 15:29
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 21.11.2017, 15:42
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Usmanmemon - 21.11.2017, 15:55
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 01.12.2017, 18:00
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Marllun - 11.12.2017, 03:40
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 11.12.2017, 04:13
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by haikalbintang - 16.12.2017, 00:00
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 16.12.2017, 23:03
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by RoyalGamer - 17.12.2017, 04:20
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 05.01.2018, 19:02
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by RogueDrifter - 05.01.2018, 19:11
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 05.01.2018, 23:37
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by RogueDrifter - 05.01.2018, 23:50
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 06.01.2018, 00:58
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by RogueDrifter - 06.01.2018, 02:27
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by haikalbintang - 20.01.2018, 09:38
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by RogueDrifter - 20.01.2018, 09:50
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by haikalbintang - 20.01.2018, 10:49
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by ItzColaBoi - 01.02.2018, 12:00
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 01.02.2018, 18:26
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Unkovic - 24.02.2018, 11:55
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by ItzColaBoi - 24.02.2018, 12:10
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by insus100 - 07.03.2018, 14:27
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 07.03.2018, 14:52
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by insus100 - 07.03.2018, 14:56
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Mike861 - 10.03.2018, 13:14
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 10.03.2018, 17:40
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Mike861 - 10.03.2018, 18:06
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Mike861 - 10.03.2018, 18:31
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 10.03.2018, 18:37
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Mike861 - 10.03.2018, 18:38
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 10.03.2018, 19:20
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Mike861 - 10.03.2018, 19:24
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 10.03.2018, 19:30
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Mike861 - 10.03.2018, 19:38
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Gammix - 10.03.2018, 20:28
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Mike861 - 10.03.2018, 20:30
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Exhibit - 26.03.2018, 15:34
Re: dini2.inc - Improved dini file processor with amazing benchmarks (aka. gini)! - by Exhibit - 28.03.2018, 15:46

Forum Jump:


Users browsing this thread: 1 Guest(s)