Advertisement
Guest User

IniFiles Speed Test

a guest
Oct 31st, 2011
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.77 KB | None | 0 0
  1. #include <a_samp>
  2. #include <IniFiles>
  3.  
  4.  
  5. #define TESTS 50
  6.  
  7. main()
  8. {
  9.     file_OS();
  10.  
  11.     new tick;
  12.  
  13.     tick=GetTickCount();
  14.     for(new i;i<TESTS;i++)
  15.     {
  16.  
  17.         file_Open("Test.ini");
  18.         file_SetStr("testing_key_for_strings", "this is a piece of text that is written to the file, you will probably want to read it again at some point!");
  19.         file_Save("Test.ini");
  20.         file_Close();
  21.  
  22.     }
  23.  
  24.     printf("Takes %d ms to Write Strings "#TESTS" times\n", GetTickCount()-tick);
  25.  
  26.  
  27.     tick=GetTickCount();
  28.     for(new i;i<TESTS;i++)
  29.     {
  30.  
  31.         file_Open("Test.ini");
  32.         file_SetVal("testing_key_for_integers", 47285);
  33.         file_Save("Test.ini");
  34.         file_Close();
  35.  
  36.     }
  37.  
  38.     printf("Takes %d ms to Write Integers "#TESTS" times\n", GetTickCount()-tick);
  39.  
  40.    
  41.     //
  42.    
  43.     tick=GetTickCount();
  44.     for(new i;i<TESTS;i++)
  45.     {
  46.  
  47.         file_Open("Test.ini");
  48.         file_SetFloat("testing_key_for_floats", 47285);
  49.         file_Save("Test.ini");
  50.         file_Close();
  51.  
  52.     }
  53.  
  54.     printf("Takes %d ms to Write Floats "#TESTS" times\n", GetTickCount()-tick);
  55.  
  56.  
  57.     //
  58.  
  59.     tick=GetTickCount();
  60.     for(new i;i<TESTS;i++)
  61.     {
  62.  
  63.         new var_str[256];
  64.         file_Open("Test.ini");
  65.         strcat(var_str, file_GetStr("testing_key_for_strings"));
  66.         file_Close();
  67.  
  68.     }
  69.  
  70.     printf("Takes %d ms to read strings "#TESTS" times\n", GetTickCount()-tick);
  71.  
  72.  
  73.     //
  74.  
  75.     tick=GetTickCount();
  76.     for(new i;i<TESTS;i++)
  77.     {
  78.  
  79.         new var_int;
  80.         file_Open("Test.ini");
  81.         var_int=file_GetVal("testing_key_for_integers");
  82.         file_Close();
  83.  
  84.     }
  85.  
  86.     printf("Takes %d ms to read integers "#TESTS" times\n", GetTickCount()-tick);
  87.  
  88.  
  89.     //
  90.  
  91.     tick=GetTickCount();
  92.     for(new i;i<TESTS;i++)
  93.     {
  94.  
  95.         new var_flt;
  96.         file_Open("Test.ini");
  97.         var_flt=file_GetVal("testing_key_for_floats");
  98.         file_Close();
  99.  
  100.     }
  101.  
  102.     printf("Takes %d ms to read floats "#TESTS" times\n", GetTickCount()-tick);
  103.  
  104.  
  105. }
  106.  
  107.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement