* 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 |
#include <a_samp>
#include <Dini2>
main() {
const ITERATIONS = 3;
const NUM_FILES = 100;
const NUM_FIELDS = 64;
new s, e;
new fileName[54];
new fieldName[64];
// START
s = GetTickCount();
//
for (new a; a < ITERATIONS; a++) {
for (new b; b < NUM_FILES; b++) {
format(fileName, sizeof fileName, "file_%i.ini", b);
#if !defined dini2_included
dini_Create(fileName);
#endif
for (new c; c < NUM_FIELDS; c++) {
format(fieldName, sizeof fieldName, "field_%i", c);
dini_Set(fileName, fieldName, "value");
}
}
}
#if defined dini2_included
for (new a; a < NUM_FILES; a++) {
format(fileName, sizeof fileName, "file_%i.ini", a);
dini_Timeout(fileName);
}
#endif
//
e = GetTickCount();
printf("Writing %i files with %i fields, %i times takes: %i ms", NUM_FILES, NUM_FIELDS, ITERATIONS, (e - s));
// END
// START
s = GetTickCount();
//
for (new a; a < ITERATIONS; a++) {
for (new b; b < NUM_FILES; b++) {
format(fileName, sizeof fileName, "file_%i.ini", b);
#if !defined dini2_included
dini_Create(fileName);
#endif
for (new c; c < NUM_FIELDS; c++) {
format(fieldName, sizeof fieldName, "field_%i", c);
dini_Get(fileName, fieldName);
}
}
}
#if defined dini2_included
for (new a; a < NUM_FILES; a++) {
format(fileName, sizeof fileName, "file_%i.ini", a);
dini_Timeout(fileName);
}
#endif
//
e = GetTickCount();
printf("Reading %i files with %i fields, %i times takes: %i ms", NUM_FILES, NUM_FIELDS, ITERATIONS, (e - s));
// END
for (new a; a < NUM_FILES; a++) {
format(fileName, sizeof fileName, "file_%i.ini", a);
dini_Remove(fileName);
}
}
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[]);
./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.
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? pawn Code:
|
Wow Gammix, you've made a lot of contributions to the community! Keep up the good work man.
+rep |
Originally Posted by Gammix
This is faster, a lot than DINI
|
Give me reasons why someone would prefer to use gini over other INI processors which have WAY WAY WAY more features and is WAY WAY WAY faster.
|
You are competing in the wrong world. Start bench-marking with y_ini or eINI. Your include provides far less features and is slower. You MUST beat y_ini in performance if you want to keep the include this simple if you WANT people to use it.
|
You'd do better if you would have forked the existing INI Processors and added new features to it.
|
Give me reasons why someone would prefer to use gini over other INI processors which have WAY WAY WAY more features and is WAY WAY WAY faster.
You are competing in the wrong world. Start bench-marking with y_ini or eINI. Your include provides far less features and is slower. You MUST beat y_ini in performance if you want to keep the include this simple if you WANT people to use it. By just looking at your code, I can guarantee you that gini is AT LEAST 10 times slower than y_ini. The only interesting feature I see is the timeout feature. You'd do better if you would have forked the existing INI Processors and added new features to it. strunpack? Why even save memory? Just give it away or at least keep it optional. Most servers have many GBs of memory and the memory saved by packing strings is insignificant. |
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.
|
Well done, great!
I created theme in Russian forum: link (This is not advertising!), don't you mind? |
dini2.inc - Improved DINI processor with multi file support and faster |
#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[])
{
}
[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