Advertisement
xhunterx

SAMP file speed test script no i/o

Apr 16th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.47 KB | None | 0 0
  1.  
  2.  
  3.  
  4. #include <a_samp>
  5.  
  6. const Iterations = 10000;
  7. new fileline = 0;
  8.  
  9. stock fdonothing() {
  10.     return 1;
  11. }
  12.  
  13. stock fdonothingr() {
  14.     return (--fileline) >= 0;
  15. }
  16.  
  17. stock File:fdonothingf() {
  18.     fileline = Iterations;
  19.     return File:1;
  20. }
  21.  
  22. #define fopen(%0) fdonothingf()
  23. #define fclose(%0) fdonothing()
  24. #define fwrite(%0) fdonothing()
  25. #define fread(%0) fdonothingr()
  26. #define fremove(%0) fdonothing()
  27. #define fexist(%0) fdonothing()
  28.  
  29. #include <dini>
  30.  
  31.  
  32. public OnFilterScriptInit() {
  33.     SetTimer(#TestSpeed, 10000, false);
  34.     return 1;
  35. }
  36.  
  37. forward TestSpeed();
  38. public TestSpeed() {
  39.     printf("Iterations = %i", Iterations);
  40.  
  41.     new start, end, str[128], File:f;
  42.     start = GetTickCount();
  43.     f = fopen("speedTest1.ini", io_write);
  44.     for(new i=0; i<Iterations; ++i) {
  45.         format(str, sizeof(str), "polozka%03i=%i\r\n", i, i);
  46.         fwrite(f, str);
  47.     }
  48.     fclose(f);
  49.     end = GetTickCount();
  50.     printf("Test1 = %i", end - start);
  51.    
  52.     start = GetTickCount();
  53.     dini_Create("speedTest3.ini");
  54.     for(new i=0; i<Iterations; ++i) {
  55.         format(str, sizeof(str), "polozka%03i", i, i);
  56.         dini_IntSet("speedTest3.ini", str, i);
  57.     }
  58.     end = GetTickCount();
  59.     printf("Test3 = %i", end - start);
  60.    
  61.     start = GetTickCount();
  62.     for(new j=0; j<Iterations; ++j) {
  63.         f = fopen("speedTest2.ini", io_write);
  64.         for(new i=0; i<1000; ++i) {
  65.             format(str, sizeof(str), "polozka%03i=%i\r\n", i, i);
  66.             fwrite(f, str);
  67.         }
  68.         fclose(f);
  69.     }
  70.     end = GetTickCount();
  71.     printf("Test2 = %i", end - start);
  72.  
  73.     return 1;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement