Advertisement
Southclaw

File Script Speed Test

Nov 4th, 2011
258
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. #define TESTS 50
  5.  
  6. main()
  7. {
  8.     file_OS();
  9.  
  10.     new tick;
  11.  
  12.     tick=GetTickCount();
  13.     for(new i;i<TESTS;i++)
  14.     {
  15.  
  16.         file_Open("Test.ini");
  17.         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!");
  18.         file_Save("Test.ini");
  19.         file_Close();
  20.  
  21.     }
  22.  
  23.     printf("Takes %d ms to Write Strings "#TESTS" times\n", GetTickCount()-tick);
  24.  
  25.  
  26.     tick=GetTickCount();
  27.     for(new i;i<TESTS;i++)
  28.     {
  29.  
  30.         file_Open("Test.ini");
  31.         file_SetVal("testing_key_for_integers", 47285);
  32.         file_Save("Test.ini");
  33.         file_Close();
  34.  
  35.     }
  36.  
  37.     printf("Takes %d ms to Write Integers "#TESTS" times\n", GetTickCount()-tick);
  38.  
  39.    
  40.     //
  41.    
  42.     tick=GetTickCount();
  43.     for(new i;i<TESTS;i++)
  44.     {
  45.  
  46.         file_Open("Test.ini");
  47.         file_SetFloat("testing_key_for_floats", 47285);
  48.         file_Save("Test.ini");
  49.         file_Close();
  50.  
  51.     }
  52.  
  53.     printf("Takes %d ms to Write Floats "#TESTS" times\n", GetTickCount()-tick);
  54.  
  55.  
  56.     //
  57.  
  58.     tick=GetTickCount();
  59.     for(new i;i<TESTS;i++)
  60.     {
  61.  
  62.         new var_str[256];
  63.         file_Open("Test.ini");
  64.         strcat(var_str, file_GetStr("testing_key_for_strings"));
  65.         file_Close();
  66.  
  67.     }
  68.  
  69.     printf("Takes %d ms to read strings "#TESTS" times\n", GetTickCount()-tick);
  70.  
  71.  
  72.     //
  73.  
  74.     tick=GetTickCount();
  75.     for(new i;i<TESTS;i++)
  76.     {
  77.  
  78.         new var_int;
  79.         file_Open("Test.ini");
  80.         var_int=file_GetVal("testing_key_for_integers");
  81.         file_Close();
  82.  
  83.     }
  84.  
  85.     printf("Takes %d ms to read integers "#TESTS" times\n", GetTickCount()-tick);
  86.  
  87.  
  88.     //
  89.  
  90.     tick=GetTickCount();
  91.     for(new i;i<TESTS;i++)
  92.     {
  93.  
  94.         new var_flt;
  95.         file_Open("Test.ini");
  96.         var_flt=file_GetVal("testing_key_for_floats");
  97.         file_Close();
  98.  
  99.     }
  100.  
  101.     printf("Takes %d ms to read floats "#TESTS" times\n", GetTickCount()-tick);
  102.  
  103.  
  104. }
  105.  
  106.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement