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

Quote:
Originally Posted by Dalayma
View Post
dini_IntSet does not work
Its working well for me, can you show your code and file where it gets saved.
Reply
#22

Example
Quote:

dini_IntSet(PlayerInfo[playerid][pName]).("GSession",(dini_Int(PlayerInfo[playerid][pName]).("GSession"))+1);

if the file is missing a line, it is not automatically created. In the old version Dini line was created and assigned a value of 0.
It can be a problem only for me =\
Reply
#23

Quote:
Originally Posted by Dalayma
View Post
Example

if the file is missing a line, it is not automatically created. In the old version Dini line was created and assigned a value of 0.
It can be a problem only for me =\
That's not the right syntax, here is how it should be: (this is the original DINI syntax)
pawn Code:
dini_IntSet(PlayerInfo[playerid][pName], "GSession", dini_Int(PlayerInfo[playerid][pName], "GSession") + 1);
Reply
#24

Quote:
Originally Posted by Kar
View Post
Theres nothing wrong with this concept, ALOT of scripts out there still use dini, people can just include this instead of dini and speed up their file functions.

Everything must be criticized in this place.. lmao.
Everything must be criticized when required because SAMP is a community driven project. I always accept critics browsing through my threads and their replies because they are constructive.

Of course, you will always find me (most of the times) critizing someone because the replies I make which appreciate are very few. I simply don't reply "Good" "Cool" , etc. Sometimes I throw away few reps to satisfy the author if he even cares about them. For Gammix, it might appear that I keep critizing him too often. It is because Gammix keeps releasing something every day and I find faults with it everytime and I just critize it so that it gets improved. Maybe I critize in a mean way or maybe I should change the way I critize. That is what others have to tell rather than complaining that everything is critized in the forums.

Quote:
Originally Posted by Gammix
View Post
Y_INI vs. eINI vs. DINI2
If the benchmarks are wrong, you may share yours or correct them, i haven't really used Y_INI or any INI processor.

Benchmarks code:
pawn Code:
#include <a_samp>

#include <YSI\y_ini>

#include <eini>

#define INI_FILE_TIMEOUT (3000)
#include <dini2>

main()
{
    new s, e;

    // Y_INI
    // Writing
    s = GetTickCount();

    new INI:handle = INI_Open("Test.ini");
    for (new i; i < 100000; i++)
    {
        INI_WriteString(handle, "Set1", "Gammix_Changed");
        INI_WriteString(handle, "Set2", "Gammix_Changed");
        INI_WriteString(handle, "Set3", "Gammix_Changed");
        INI_WriteString(handle, "Set4", "Gammix_Changed");
        INI_WriteString(handle, "Set5", "Gammix_Changed");
        INI_WriteString(handle, "Set6", "Gammix_Changed");
        INI_WriteString(handle, "Set7", "Gammix_Changed");
        INI_WriteString(handle, "Set8", "Gammix_Changed");
        INI_WriteString(handle, "Set9", "Gammix_Changed");
        INI_WriteString(handle, "Set10", "Gammix_Changed");
    }
    INI_Close(handle);

    e = GetTickCount();
    printf("[Y_INI] Write string to 10 fields 100000 times -> %i ms", e - s);

    // Reading
    s = GetTickCount();

    for (new i; i < 100000; i++)
    {
        INI_ParseFile("Test.ini", "LoadFile");
    }

    e = GetTickCount();
    printf("[Y_INI] Read string from 10 fields 100000 times -> %i ms", e - s);



    // eINI
    // Writing
    s = GetTickCount();

    handle = INI::OpenINI("Test2.ini", INI_WRITE);
    for (new i; i < 100000; i++)
    {
        INI::WriteString(handle, "Gammix_Changed", "Set1", "");
        INI::WriteString(handle, "Gammix_Changed", "Set2", "");
        INI::WriteString(handle, "Gammix_Changed", "Set3", "");
        INI::WriteString(handle, "Gammix_Changed", "Set4", "");
        INI::WriteString(handle, "Gammix_Changed", "Set5", "");
        INI::WriteString(handle, "Gammix_Changed", "Set6", "");
        INI::WriteString(handle, "Gammix_Changed", "Set7", "");
        INI::WriteString(handle, "Gammix_Changed", "Set8", "");
        INI::WriteString(handle, "Gammix_Changed", "Set9", "");
        INI::WriteString(handle, "Gammix_Changed", "Set10", "");
    }
    INI::CloseINI(handle);

    e = GetTickCount();
    printf("[eINI] Write string to 10 fields 100000 times -> %i ms", e - s);

    // Reading
    s = GetTickCount();

    handle = INI::OpenINI("Test2.ini", INI_READ);
    for (new i; i < 100000; i++)
    {
        INI::ReadString(handle, "", "Set1", "");
        INI::ReadString(handle, "", "Set2", "");
        INI::ReadString(handle, "", "Set3", "");
        INI::ReadString(handle, "", "Set4", "");
        INI::ReadString(handle, "", "Set5", "");
        INI::ReadString(handle, "", "Set6", "");
        INI::ReadString(handle, "", "Set7", "");
        INI::ReadString(handle, "", "Set8", "");
        INI::ReadString(handle, "", "Set9", "");
        INI::ReadString(handle, "", "Set10", "");
    }

    e = GetTickCount();
    printf("[eINI] Read string from 10 fields 100000 times -> %i ms", e - s);
   


    // DINI2
    // Writing
    s = GetTickCount();

    dini_Create("Test3.ini");
    for (new i; i < 100000; i++)
    {
        dini_Set("Test3.ini", "Set1", "Gammix_Changed");
        dini_Set("Test3.ini", "Set2", "Gammix_Changed");
        dini_Set("Test3.ini", "Set3", "Gammix_Changed");
        dini_Set("Test3.ini", "Set4", "Gammix_Changed");
        dini_Set("Test3.ini", "Set5", "Gammix_Changed");
        dini_Set("Test3.ini", "Set6", "Gammix_Changed");
        dini_Set("Test3.ini", "Set7", "Gammix_Changed");
        dini_Set("Test3.ini", "Set8", "Gammix_Changed");
        dini_Set("Test3.ini", "Set9", "Gammix_Changed");
        dini_Set("Test3.ini", "Set10", "Gammix_Changed");
    }
    dini_Timeout("Test3.ini");

    e = GetTickCount();
    printf("[DINI2] Write string to 10 fields 100000 times -> %i ms", e - s);
   
    // Reading
    s = GetTickCount();

    dini_Create("Test3.ini");
    for (new i; i < 100000; i++)
    {
        dini_Get("Test3.ini", "Set1");
        dini_Get("Test3.ini", "Set2");
        dini_Get("Test3.ini", "Set3");
        dini_Get("Test3.ini", "Set4");
        dini_Get("Test3.ini", "Set5");
        dini_Get("Test3.ini", "Set6");
        dini_Get("Test3.ini", "Set7");
        dini_Get("Test3.ini", "Set8");
        dini_Get("Test3.ini", "Set9");
        dini_Get("Test3.ini", "Set10");
    }
    dini_Timeout("Test3.ini");

    e = GetTickCount();
    printf("[DINI2] Read string from 10 fields 100000 times -> %i ms", e - s);
}

forward LoadFile(tag[],key[],value[]);
public LoadFile(tag[],key[],value[])
{
}
Results:
Code:
[15:59:11] [Y_INI] Write string to 10 fields 100000 times -> 2944 ms
[15:59:19] [Y_INI] Read string from 10 fields 100000 times -> 8173 ms

[15:59:20] [eINI] Write string to 10 fields 100000 times -> 965 ms
[15:59:21] [eINI] Read string from 10 fields 100000 times -> 838 ms

[15:59:21] [DINI2] Write string to 10 fields 100000 times -> 833 ms
[15:59:22] [DINI2] Read string from 10 fields 100000 times -> 870 ms
@Yashas: I guess you were wrong on you claiming this WAY WAY WAY slower. Its alot faster than YINI and step further than eINI even with such syntax it supports.
1. When I claimed that gini is WAY slower you had 123218743987593479535 strunpack and strpacks. Do the test with your old version and you will find it to be WAY WAY slower.
2. You just wrote the worst possible code for both YINI and eINI. Both these processors provide section id system which cuts down the speed significantly. Maybe even 10x faster with section ids.
3. Your speed tests don't consider opening/writing time at all. In fact, eINI is slower than YINI while parsing given the fact that eINI provides lot of customizable options, it has to be slow. However, the range of features it provides will circumvent the speed loss. In fact, eINI writes and reads faster which compensates for the speed loss while opening the file.
4. YINI and eINI provide dynamic loading system which will just throw your system out of the competition.
5. eINI provides keyid system too which if used could be even 20x faster than YINI but that would be cheating because not everybody knows how to use it and most people would not use it. So the mainstream competition should remain within normal Read/Write functions but there should be at least reasonable optimizations.

If you were to implement those features in your Improved DINI. You can't even call it improved DINI. It would simply be a new INI processor.

I can't do proper speed test so all my new speed claims in this reply are mere guesses.

At first the situation was, gini was slow and did not have enough features. Even though you called it an update for dini it wasn't still worth it. People had to switch to SQL or a new INI processor. Now with your str(un)pack removed, gini meets eINI and YINI when the worst possible code of eINI and YINI is used.

Frankly, I don't want to hurt your feelings but you have too much ego. You are don't like critizisim for some reason. Sometimes you keep arguing about the same thing again and again in spite of best efforts of many to convience you.

I just saw a post where Crayder said the very same thing which I had already told you at least 5 times with big explaination that "you CANNOT add prints/formats/etc inside speed test code". With your logic I can prove that dini is as fast as eINI. I will add 100000 printfs inside the speed test loop and prove that eINI takes 1000ms and dini takes 1001ms so they are almost the same. You say that everytime there has to be code inside becaz its practical but that is not true with speed tests.

If you add just one/two printf inside the command, you will find that ZCMD comes close to IZCMD and you may even conclude that they are the same.

In fact, all performance optimizations loose their meaning if you do speed tests that way beause every optimization will appear to be negligible.

If you still don't know why, get a course on debugging & testing. I am not sure if you are a teen or doing your engineering in CS but anyway the best thing for you right now is to check testing docs and procedures.
Reply
#25

Quote:
Originally Posted by Yashas
View Post
...
In my previous replies i told you why i don't want to make another INI processor; "Waste of time". "You can judge by the number of users eINI have." eINI is the newest one out there, faster than DINI and YINI but people still stick with DINI who are using old scripts or are unaware and others are satisfied with YINI. So you should have realized by now there is no point in inventing something new, so i decided to atleast improve upon DINI with my DINI2 which i find people have started using.

Instead of just speaking of my wrong coding practice, share some of your code which i'll find useful and better in ways.

And why would you consider old arguments here?
Trying to be sarcastic?

(i never expressed myself rude against your criticism unless you were provocative)
Reply
#26

Is that faster than this https://sampforum.blast.hk/showthread.php?tid=581453
Reply
#27

I don't think so, INI processors never been, never will be faster than SQL.
Reply
#28

Gammix i'm want use dini2 in lethaldudb2 (http://pastebin.com/UwsfdScb) but i have problem

Quote:

udb_RenameUser(oldname,newname); (use frenametextfile) - old acc not delete

Quote:

line format - dUserSetINT(PlayerInfo[playerid][pName]).("TOS",(dUserINT(PlayerInfo[playerid][pName]).("TOS"))+1); - not change parameter "TOS" in player (syntax not help)

You may help or sync dini2 witch lethaldudb2 ?
Reply
#29

Quote:
Originally Posted by Dalayma
View Post
Gammix i'm want use dini2 in lethaldudb2 (http://pastebin.com/UwsfdScb) but i have problem




You may help or sync dini2 witch lethaldudb2 ?
I tested the code with dini2 and it works flawless. Just replace <dini> with <dini2>.
Reply
#30

Update v2.3.3:
- Improved timeout config, now the include will timeout index 0 file when more than "INI_MAX_INSTANCES" files are opened.
- Decreased timeout limit, was unnecessarily high upto 1000!
Reply
#31

bug frenametextfile, not removed old files
Reply
#32

Quote:
Originally Posted by 14_KaPaT
Посмотреть сообщение
bug frenametextfile, not removed old files
There is no such function but DINI_fcopytextfile, which makes a duplicate, you can remove the previous file for a rename.
Reply
#33

Quote:
Originally Posted by ******
Посмотреть сообщение
The first test is writing a single INI file with 1,000,000 lines. The second test is more accurately testing writing a single file with 10 lines. It is the same with reading:

Open the file ONCE. Parse the file ONCE. Read some easy variables a load of times. The thing you need to be timing is "INI::OpenINI". That is the slow part, and that is why y_ini's reading was so much slower:

pawn Код:
for (new i; i < 100000; i++)
    {
        INI_ParseFile("Test.ini", "LoadFile");
    }
It makes sense to constantly parse inside the loop insteda of just one time because practically you don't open one file while updating player record etc.
I have made a new speed test above: (I am not even touching the redaing part for YINI and it slower already according to the test if it's done right)

Result:
PHP код:
[18:20:516134 ms
[18:21:0210922 ms 
Code:
PHP код:
#include <a_samp>
#include <dini2>
#include <YSI\y_ini>
main()
{
    new 
se;
    
    
GetTickCount();
    for (new 
i100000i++)
    {
        
dini_Get("Test1.ini""Set1");
        
dini_Int("Test1.ini""Set2");
        
dini_Float("Test1.ini""Set3");
        
dini_Timeout("Test1.ini");
    }
    
GetTickCount();
    
printf("%i ms"e-s);
    
GetTickCount();
    for (new 
i100000i++)
    {
        
INI_ParseFile("Test2.ini""LoadFile");
    }
    
GetTickCount();
    
printf("%i ms"e-s);

Quote:
Originally Posted by ******
Посмотреть сообщение
Your eINI code is more similar to your DINI2 code, but again because you are doing the hard part only once, any real differences get lost in the noise.

Again: I don't know if this system truly is faster because your tests don't show anything meaningful. You skip the hard work in some tests, repeat it in others, then claim that the first test was faster - of course it is!
Here is a speed test comparing eINI and dini2/gini reading speed, similarly before, i open and close file each time inside the loop:

Result:
PHP код:
[18:29:106182 ms
[18:29:187756 ms 
Code:
PHP код:
#include <a_samp>
#include <dini2>
#include <eINI>
main()
{
    new 
se;
    
    
GetTickCount();
    for (new 
i100000i++)
    {
        
dini_Get("Test1.ini""Set1");
        
dini_Int("Test1.ini""Set2");
        
dini_Float("Test1.ini""Set3");
        
dini_Timeout("Test1.ini");
    }
    
GetTickCount();
    
printf("%i ms"e-s);
    
GetTickCount();
    new 
INI:handleread;
    for (new 
i100000i++)
    {
        
handle INI::OpenINI("Test1.ini"INI_READ);
        
INI::ReadString(handle"""Set1""");
        
INI::ReadInteger(handleread"Set2""");
        
INI::ReadFloat(handleFloat:read"Set3""");
        
INI::CloseINI(handle);
    }
    
GetTickCount();
    
printf("%i ms"e-s);

Reply
#34

Nice, thx.
Reply
#35

Quote:

dini_UnSet(const file[], const field[]);
dini_IsSet(const file[], const field[]);

for what?
Reply
#36

Nice work but i have mini proplem, 'Unfined symbol 'dini_Isset' please help
Edit: solved, sorry it was my fualt becuse on old Dini it was lowercase charecters function but on gini it was capital
Reply
#37

idk why but dini_Int and dini_Float work incorrect.
dini_Int get bad value.
Reply
#38

Quote:
Originally Posted by JokeyL
Посмотреть сообщение
idk why but dini_Int and dini_Float work incorrect.
dini_Int get bad value.
Let me see how your file looks (the .ini file screenshot). Maybe you have spaces on either sides of "=" in it or the values aren't strings!
Reply
#39

Nope i don't have any spaces in file.
++ if player not registered, dini_Int automatically create file with -1 values

Look at JokeyL.ini

Код:
pLogged=1
pScore=-1
pCash=-1
pKills=-1
pDeaths=-1
pVisits=-1
Example of using:

Use in OnPlayerDeath:
playerInfo[killerid][Kills] += 1;

Load:
playerInfo[playerid][Kills] = dini_Int(path, "pKills");

Save:
dini_IntSet(path, "pKills", playerInfo[playerid][Kills]);
Reply
#40

Quote:
Originally Posted by JokeyL
Посмотреть сообщение
Nope i don't have any spaces in file.
++ if player not registered, dini_Int automatically create file with -1 values

Look at JokeyL.ini

Код:
pLogged=1
pScore=-1
pCash=-1
pKills=-1
pDeaths=-1
pVisits=-1
Example of using:

Use in OnPlayerDeath:
playerInfo[killerid][Kills] += 1;

Load:
playerInfo[playerid][Kills] = dini_Int(path, "pKills");

Save:
dini_IntSet(path, "pKills", playerInfo[playerid][Kills]);
Ok i got the problem here, that can be fixed easily. Actually my ini code creates the file if it's not existing. I guess this feature should only work with "Set" functions.

I'll make an update plus some optimizations.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)