Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <a_mysql>
- #include <mxINI>
- main()
- {
- print("\n------------TEST------------------");
- print("----------------------------------\n");
- }
- new DB:TestDB;
- new mysql_connect_ID;
- #define COUNT 100
- enum ormTest
- {
- ORM:ID,
- id,
- value,
- }
- new OrmTest[ormTest];
- stock Pause() for(new i; i != 40000000; i++) {} //Примерно 1 сек
- public OnGameModeInit()
- {
- SetGameModeText("test");
- mysql_connect_ID = mysql_connect("localhost", "root", "testpawn", ""), mysql_log(LOG_DEBUG);
- TestDB = db_open("test.db");
- db_query (TestDB, "CREATE TABLE IF NOT EXISTS `account` (`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `value` INTEGER)");
- db_query (TestDB, "PRAGMA synchronous=OFF; PRAGMA journal_mode=OFF;");
- mysql_function_query(mysql_connect_ID, "CREATE TABLE IF NOT EXISTS `account` ( `id` INT NOT NULL AUTO_INCREMENT , `value` INT NOT NULL , PRIMARY KEY (`id`) ) ENGINE = InnoDB", false, "", "");
- mysql_function_query(mysql_connect_ID, "CREATE TABLE IF NOT EXISTS `account2` ( `id` INT NOT NULL AUTO_INCREMENT , `value` INT NOT NULL , PRIMARY KEY (`id`) ) ENGINE = InnoDB", false, "", "");
- new testtime, string[128], file;
- testtime = GetTickCount();
- for (new i; i != COUNT; i++)
- {
- format(string, sizeof(string), "Test_%d.ini", i+1);
- file = ini_createFile(string);
- ini_setInteger(file, "value", i);
- ini_closeFile(file);
- }
- printf ( "[mxINI]Создание %i ms.(%i iterations)", GetTickCount () - testtime, COUNT);
- testtime = GetTickCount();
- for (new i; i != COUNT; i++)
- {
- format(string, sizeof(string), "Test_%d.ini", i+1);
- file = ini_openFile(string);
- ini_setInteger(file, "value", i+1);
- ini_closeFile(file);
- }
- printf ( "[mxINI]Обновление %i ms.(%i iterations)", GetTickCount () - testtime, COUNT);
- testtime = GetTickCount();
- for (new i; i != COUNT; i++)
- {
- format(string, sizeof(string), "Test_%d.ini", i+1);
- fremove(string);
- }
- printf ( "[file]Удаление %i ms.(%i iterations)\n", GetTickCount () - testtime, COUNT);
- testtime = GetTickCount();
- for (new i; i != COUNT; i++)
- {
- format(string, sizeof(string), "INSERT INTO `account` (`value`) VALUES ('%i')", i);
- db_query(TestDB, string);
- }
- printf ( "[SQLite]Создание %i ms.(%i iterations)", GetTickCount () - testtime, COUNT);
- testtime = GetTickCount();
- for (new i; i != COUNT; i++)
- {
- format(string, sizeof(string), "UPDATE `account` SET `value` = '%i' WHERE `id` = '%i'", i+50, i+1);
- db_query(TestDB, string);
- }
- printf ( "[SQLite]Обновление %i ms.(%i iterations)", GetTickCount () - testtime, COUNT);
- testtime = GetTickCount();
- for (new i; i != COUNT; i++)
- {
- format(string, sizeof(string), "DELETE FROM `account` WHERE `id` = '%i'", i+1);
- db_query(TestDB, string);
- }
- printf ( "[SQLite]Удаление %i ms.(%i iterations)\n", GetTickCount () - testtime, COUNT);
- testtime = GetTickCount();
- for (new i; i != COUNT; i++)
- {
- format(string, sizeof(string), "INSERT INTO `account` (`value`) VALUES ('%i')", i+1);
- mysql_function_query(mysql_connect_ID, string, false, "", "");
- }
- printf ( "[MySQL]Создание %i ms.(%i iterations)", GetTickCount () - testtime, COUNT);
- Pause(); //Пауза Без неё мускул не успевает обрабатывать запросы
- testtime = GetTickCount();
- for (new i; i != COUNT; i++)
- {
- format(string, sizeof(string), "UPDATE `account` SET `value` = '%i' WHERE `id` = '%i'", i+50, i+1);
- mysql_function_query(mysql_connect_ID, string, false, "", "");
- }
- printf ( "[MySQL]Обновление %i ms.(%i iterations)", GetTickCount () - testtime, COUNT);
- Pause(); //Пауза Без неё мускул не успевает обрабатывать запросы
- testtime = GetTickCount();
- for (new i; i != COUNT; i++)
- {
- format(string, sizeof(string), "DELETE FROM `account` WHERE `id` = '%i'", i+1);
- mysql_function_query(mysql_connect_ID, string, false, "", "");
- }
- printf ( "[MySQL]Удаление %i ms.(%i iterations)\n", GetTickCount () - testtime, COUNT);
- Pause(); //Пауза Без неё мускул не успевает обрабатывать запросы
- testtime = GetTickCount();
- OrmTest[ID] = orm_create("account2");
- orm_addvar_int(OrmTest[ID], OrmTest[id], "id");
- orm_addvar_int(OrmTest[ID], OrmTest[value], "value");
- for (new i; i != COUNT; i++)
- {
- OrmTest[value] = i;
- orm_insert(OrmTest[ID]);
- }
- printf ( "[ORM]Создание %i ms.(%i iterations)", GetTickCount () - testtime, COUNT);
- Pause(); //Пауза Без неё мускул не успевает обрабатывать запросы
- testtime = GetTickCount();
- for (new i; i != COUNT; i++)
- {
- OrmTest[id] = i+1;
- OrmTest[value] = i+50;
- orm_setkey(OrmTest[ID], "id");
- orm_update(OrmTest[ID]);
- }
- printf ( "[ORM]Обновление %i ms.(%i iterations)", GetTickCount () - testtime, COUNT);
- Pause(); //Пауза Без неё мускул не успевает обрабатывать запросы
- testtime = GetTickCount();
- for (new i; i != COUNT; i++)
- {
- OrmTest[id] = i+1;
- OrmTest[value] = i+50;
- orm_setkey(OrmTest[ID], "id");
- orm_delete(OrmTest[ID]);
- }
- orm_destroy(OrmTest[ID]);
- printf ( "[ORM]Удаление %i ms.(%i iterations)", GetTickCount () - testtime, COUNT);
- db_close(TestDB);
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnQueryError(errorid, error[], callback[], query[], connectionHandle)
- {
- printf("MySQL Error: [%d]%s", errorid, error);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement