OK, you may have created the fastest INI script by providing as few features as possible.
BUT: It seems that it doesn't work correctly! (Values are correct until IntVar00020) ==> Hash collisions?
pawn Код:
#include <a_samp>// Change this value and buffer sizes will change in all includes (I've modified them to take INI_CMP_BUFFER_SIZE as buffer sizes when it's defined.)#define INI_CMP_BUFFER_SIZE (128)// They are very slow compared to the other scripts... might be annoying.#define USE_DINI_AND_DJSON true#include <INIcmp\y_ini> // https://sampforum.blast.hk/showthread.php?tid=175565#include <INIcmp\Double-O-Files> // https://sampforum.blast.hk/showthread.php?tid=176498// DOF2 will take the MAX_ENTRIES definitions etc. from DOF1.#include <INIcmp\Double-O-Files_2> // https://sampforum.blast.hk/showthread.php?tid=253715#if USE_DINI_AND_DJSON == true #include <INIcmp\Dini> // https://sampforum.blast.hk/showthread.php?tid=50 #include <INIcmp\djson> // https://sampforum.blast.hk/showthread.php?tid=48439 #else #pragma unused ret_memcpy#endif#include <INIcmp\mxINI> // https://sampforum.blast.hk/showthread.php?tid=111746#include <INIcmp\Fini> // https://sampforum.blast.hk/showthread.php?tid=214660#include <INIcmp\cini> // https://sampforum.blast.hk/showthread.php?tid=216668#include <INIcmp\SII> // https://sampforum.blast.hk/showthread.php?tid=58458#include <INIcmp\bIni> // https://sampforum.blast.hk/showthread.php?tid=281012#include <INIcmp\bIni_v2> // https://sampforum.blast.hk/showthread.php?tid=281264#include <INIcmp\SINI> // https://sampforum.blast.hk/showthread.php?tid=262795#include <INIcmp\bfx_ini> // http://bfx-software.net/index.php?page=T...hreadID=15//READ//READ//READ//READ//READ//READ//READ//READ//READ//READ//READ//READ//READ//READ//READ//READ//READ/*
Modifications:
- Buffer sizes are now defined with INI_CMP_BUFFER_SIZE in DOF 1 & 2, mxINI, Fini, SII, bIni, SINI and bfx_ini.
- Renamed tag INI_ in SII to SII_INI_
- Renamed tag INI_ in bIni to bIni_INI_
- static variables in Fini (because of collisions with SINI
Info:
- I can't use cini correctly here...
*///READ//READ//READ//READ//READ//READ//READ//READ//READ//READ//READ#define MAX (INI_CMP_BUFFER_SIZE - 1)#define WRITE_INT i // random(1000)public OnFilterScriptInit
(){ #if USE_DINI_AND_DJSON == true djson_GameModeInit
();
#endif file_OS
();
new k;
new seed
= GetTickCount
();
while(k
++ < 50) { printf("\nFileID=%d (%d entries)",k,MAX
);
new t,file
[64],string
[64];
new INI:yini,
mxini,
val;
print (" ");
print(">>> Write the values <<<");
//Double-O-Files t
=GetTickCount
();
format(file,
sizeof(file
),
"DOFfile%03d_%d.ini",k,seed
);
DOF_CreateFile
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
DOF_SetInt
(file,string,WRITE_INT
);
} DOF_SaveFile
();
DOF_SetFile
("");
printf("DOF SET: t=%d",GetTickCount
()-t
);
//Double-O-Files 2 t
=GetTickCount
();
format(file,
sizeof(file
),
"DOF2file%03d_%d.ini",k,seed
);
DOF2::CreateFile
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
DOF2::SetInt
(file,string,WRITE_INT
);
} DOF2::WriteFile
();
DOF2::SetFile
("");
printf("DOF2 SET: t=%d",GetTickCount
()-t
);
//y_ini t
=GetTickCount
();
format(file,
sizeof(file
),
"YINIfile%03d_%d.ini",k,seed
);
yini
= INI_Open
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
INI_WriteInt
(yini, string,WRITE_INT
);
} INI_Close
(yini
);
printf("YINI SET: t=%d",GetTickCount
()-t
);
//SII t
=GetTickCount
();
format(file,
sizeof(file
),
"SIIfile%03d_%d.ini",k,seed
);
SII_INI_Open
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
SII_INI_WriteInt
(string, WRITE_INT
);
} SII_INI_Save
();
SII_INI_Close
();
printf("SII SET: t=%d",GetTickCount
()-t
);
//mxINI t
=GetTickCount
();
format(file,
sizeof(file
),
"MXINIfile%03d_%d.ini",k,seed
);
mxini
= ini_createFile
(file
);
if (mxini
< 0) mxini
= ini_openFile
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
ini_setInteger
(mxini, string, WRITE_INT
);
} ini_closeFile
(mxini
);
printf("MXINI SET: t=%d",GetTickCount
()-t
);
//cini t
=GetTickCount
();
format(file,
sizeof(file
),
"CINIfile%03d_%d.ini",k,seed
);
cini_Create
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
cini_FSave
(file,
"d", string, WRITE_INT
);
} printf("CINI SET: t=%d",GetTickCount
()-t
);
//Fini t
=GetTickCount
();
format(file,
sizeof(file
),
"FINIfile%03d_%d.ini",k,seed
);
Fini_Create
(file
);
Fini_OpenFile
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
Fini_SetVal
(string, WRITE_INT
);
} Fini_SaveFile
(file
);
Fini_CloseFile
();
printf("FINI SET: t=%d",GetTickCount
()-t
);
//bIni t
=GetTickCount
();
format(file,
sizeof(file
),
"BINIfile%03d_%d.ini",k,seed
);
bIni_INI_Create
(file
);
bIni_INI_Open
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
bIni_INI_WriteInt
(string, WRITE_INT
);
} bIni_INI_Save
();
bIni_INI_Close
();
printf("BINI SET: t=%d",GetTickCount
()-t
);
//bIni v2 t
=GetTickCount
();
format(file,
sizeof(file
),
"BINIV2file%03d_%d.ini",k,seed
);
bIni_v2_INI_Create
(file
);
bIni_v2_INI_Open
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
bIni_v2_INI_WriteInt
(string, WRITE_INT
);
} bIni_v2_INI_Save
();
bIni_v2_INI_Close
();
printf("BINIV2 SET: t=%d",GetTickCount
()-t
);
//SINI t
=GetTickCount
();
format(file,
sizeof(file
),
"SINIfile%03d_%d.ini",k,seed
);
file_Create
(file
);
file_Open
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
file_SetVal
(string, WRITE_INT
);
} file_Save
(file
);
file_Close
();
printf("SINI SET: t=%d",GetTickCount
()-t
);
//bfx_ini t
=GetTickCount
();
format(file,
sizeof(file
),
"BFXINIfile%03d_%d.ini",k,seed
);
CreateINI
(file
);
OpenINI
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
SetKeyInt
(string, WRITE_INT
);
} SaveINI
();
CloseINI
();
printf("BFXINI SET: t=%d",GetTickCount
()-t
);
#if USE_DINI_AND_DJSON == true //Dini t
=GetTickCount
();
format(file,
sizeof(file
),
"DINIfile%03d_%d.ini",k,seed
);
dini_Create
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
dini_IntSet
(file,string,WRITE_INT
);
} printf("DINI SET: t=%d",GetTickCount
()-t
);
//DJSON t
=GetTickCount
();
format(file,
sizeof(file
),
"DJSONfile%03d_%d.ini",k,seed
);
djCreateFile
(file
);
djAutocommit
(false
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"Test/IntVal%05d",i
);
djSetInt
(file,string,WRITE_INT
);
} djCommit
(file
);
djAutocommit
(true
);
printf("DJSON SET: t=%d",GetTickCount
()-t
);
#endif /*
GET GET GET GET GET
*/ print (" ");
print(">>> Read the values <<<");
//Double-O-Files t
=GetTickCount
();
format(file,
sizeof(file
),
"DOFfile%03d_%d.ini",k,seed
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
DOF_GetInt
(file,string
);
} printf("DOF GET: t=%d",GetTickCount
()-t
);
//Double-O-Files 2 t
=GetTickCount
();
format(file,
sizeof(file
),
"DOF2file%03d_%d.ini",k,seed
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
DOF2::GetInt
(file,string
);
} //DOF2::ParseFile (file, 0, true); // Loop or this. printf("DOF2 GET: t=%d",GetTickCount
()-t
);
//y_ini t
=GetTickCount
();
format(file,
sizeof(file
),
"YINIfile%03d_%d.ini",k,seed
);
INI_ParseFile
(file, string
);
// That's how Y_INI works? Loading everything in one function, isn't it? /*
for(new i=0;i<1000;i++)
{
format(string,sizeof(string),"IntVal%05d",i);
}
*/ printf("YINI GET: t=%d",GetTickCount
()-t
);
t
=GetTickCount
();
format(file,
sizeof(file
),
"SIIfile%03d_%d.ini",k,seed
);
SII_INI_Open
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
SII_INI_ReadInt
(string
);
} SII_INI_Save
();
SII_INI_Close
();
printf("SII GET: t=%d",GetTickCount
()-t
);
//mxINI t
=GetTickCount
();
format(file,
sizeof(file
),
"MXINIfile%03d_%d.ini",k,seed
);
mxini
= ini_createFile
(file
);
if (mxini
< 0) mxini
= ini_openFile
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
ini_getInteger
(mxini, string, val
);
} ini_closeFile
(mxini
);
printf("MXINI GET: t=%d",GetTickCount
()-t
);
//cini t
=GetTickCount
();
format(file,
sizeof(file
),
"CINIfile%03d_%d.ini",k,seed
);
cini_Create
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
cini_FLoad
(file,
"d", string, val
);
} printf("CINI GET: t=%d",GetTickCount
()-t
);
//Fini t
=GetTickCount
();
format(file,
sizeof(file
),
"FINIfile%03d_%d.ini",k,seed
);
Fini_OpenFile
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
val
= Fini_GetValue
(string
);
} Fini_CloseFile
();
printf("FINI GET: t=%d",GetTickCount
()-t
);
//bIni t
=GetTickCount
();
format(file,
sizeof(file
),
"BINIfile%03d_%d.ini",k,seed
);
bIni_INI_Open
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
val
= strval (bIni_INI_ReadString
(string
));
} bIni_INI_Close
();
printf("BINI GET: t=%d",GetTickCount
()-t
);
//bIni v2 t
=GetTickCount
();
format(file,
sizeof(file
),
"BINIV2file%03d_%d.ini",k,seed
);
bIni_v2_INI_Open
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
val
= strval (bIni_v2_INI_ReadString
(string
));
} bIni_v2_INI_Close
();
printf("BINIV2 GET: t=%d",GetTickCount
()-t
);
//SINI t
=GetTickCount
();
format(file,
sizeof(file
),
"SINIfile%03d_%d.ini",k,seed
);
file_Open
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
val
= file_GetVal
(string
);
} file_Close
();
printf("SINI GET: t=%d",GetTickCount
()-t
);
//BFXINI t
=GetTickCount
();
format(file,
sizeof(file
),
"BFXINIfile%03d_%d.ini",k,seed
);
OpenINI
(file
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
val
= ReadIntKey
(string
);
} CloseINI
();
printf("BFXINI GET: t=%d",GetTickCount
()-t
);
#if USE_DINI_AND_DJSON == true //Dini t
=GetTickCount
();
format(file,
sizeof(file
),
"DINIfile%03d_%d.ini",k,seed
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"IntVal%05d",i
);
dini_Int
(file,string
);
} printf("DINI GET: t=%d",GetTickCount
()-t
);
//DJSON t
=GetTickCount
();
format(file,
sizeof(file
),
"DJSONfile%03d_%d.ini",k,seed
);
for(new i
=0;i
<MAX;i
++) { format(string,
sizeof(string
),
"Test/IntVal%05d",i
);
djInt
(file,string
);
} printf("DJSON GET: t=%d",GetTickCount
()-t
);
#endif print("-=-=-=-=-=-=-=-=-=-=-=-");
print(" ");
} return 1;
}public OnFilterScriptExit
(){ DOF_Exit
();
DOF2::Exit
();
#if USE_DINI_AND_DJSON == true djson_GameModeExit
();
#endif return 1;
}