Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <a_mysql>
- #define ITER_COUNT 100
- #define MYSQL_TEST_THREAD 4
- new
- DB:g_Sqlite,
- DBResult:g_Res,
- g_Str[128],
- g_Ticks[2];
- main(){}
- public OnGameModeInit()
- {
- //------------------------- sqlite---------------------------------------------
- print("SQLite test starting...");
- g_Sqlite = db_open("Test.SQLITE");
- //Insert
- g_Ticks[0] = GetTickCount();
- for(new i = 0; i < ITER_COUNT; i++)
- {
- db_free_result(db_query(g_Sqlite, "INSERT INTO `Test` VALUES('STRRRRRRRRRRRRIIIIIIIIIIIIIIIIIIING TEEEEEEEEEST', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)"));
- }
- g_Ticks[1] = GetTickCount();
- printf("SQLite Insert: %d queries in %d ms", ITER_COUNT, g_Ticks[1]-g_Ticks[0]);
- //Select
- g_Ticks[0] = GetTickCount();
- for(new i = 0; i < ITER_COUNT; i++)
- {
- g_Res = db_query(g_Sqlite, "SELECT `String` FROM `Test` LIMIT 1");
- db_get_field_assoc(g_Res,"String",g_Str, sizeof(g_Str));
- db_free_result(g_Res);
- }
- g_Ticks[1] = GetTickCount();
- printf("SQLite Select: %d queries in %d ms", ITER_COUNT, g_Ticks[1]-g_Ticks[0]);
- printf(" >> SQLite Last select result: %s",g_Str);
- //update
- g_Ticks[0] = GetTickCount();
- for(new i = 0; i < ITER_COUNT; i++)
- {
- db_free_result(db_query(g_Sqlite, "Update `Test` SET `String` = 'newstring'"));
- }
- g_Ticks[1] = GetTickCount();
- printf("SQLite Update: %d queries in %d ms", ITER_COUNT, g_Ticks[1]-g_Ticks[0]);
- db_close(g_Sqlite);
- //------------------------- Mysql ------------------------------------------------
- print("MySQL test starting....");
- //insert
- mysql_connect("localhost", "root", "SAMP", "Kyolovestacos8");
- g_Ticks[0] = GetTickCount();
- for(new i = 0; i < ITER_COUNT; i++)
- {
- mysql_query("INSERT INTO `Test` VALUES('STRRRRRRRRRRRRIIIIIIIIIIIIIIIIIIING TEEEEEEEEEST', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)");
- mysql_store_result(); // to make it a bit fair (even though its dumb >.>)
- mysql_free_result();
- }
- g_Ticks[1] = GetTickCount();
- printf("MySQL Insert: %d queries in %d ms", ITER_COUNT, g_Ticks[1]-g_Ticks[0]);
- //Select
- g_Ticks[0] = GetTickCount();
- for(new i = 0; i < ITER_COUNT; i++)
- {
- mysql_query("SELECT `String` FROM `Test` LIMIT 1");
- mysql_store_result();
- if(mysql_retrieve_row())
- {
- mysql_fetch_field_row(g_Str,"String");
- }
- mysql_free_result();
- }
- g_Ticks[1] = GetTickCount();
- printf("MySQL Select: %d queries in %d ms", ITER_COUNT, g_Ticks[1]-g_Ticks[0]);
- printf(" >> MySQL Last select result: %s",g_Str);
- //update
- g_Ticks[0] = GetTickCount();
- for(new i = 0; i < ITER_COUNT; i++)
- {
- mysql_query("Update `Test` SET `String` = 'newstring'");
- mysql_store_result(); // once again to be a little more fair
- mysql_free_result();
- }
- g_Ticks[1] = GetTickCount();
- printf("MySQL Update: %d queries in %d ms", ITER_COUNT, g_Ticks[1]-g_Ticks[0]);
- mysql_close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement