Advertisement
BigETI

memory_benchmark2.pwn

Jan 17th, 2015
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.87 KB | None | 0 0
  1. #include <a_samp>
  2. //#define SECURE_MEMORY_PLUGIN
  3. #include <memory>
  4.  
  5. #define MEM_SIZE    (1024)
  6. #define LOOP        (100000)
  7.  
  8. public OnFilterScriptInit()
  9. {
  10.     print("\n==================================");
  11.     print("= Memory access plugin benchmark =");
  12.     print("==================================\n");
  13.     new Pointer:ptr = MEM_malloc(MEM_SIZE), i, j, k, a, b, dummy;
  14.     if(ptr)
  15.     {
  16.         for(i = 0; i < 5; i++)
  17.         {
  18.             a = GetTickCount();
  19.             for(j = 0; j < LOOP; j++) for(k = 0; k < MEM_SIZE; k++) MEM_set_val(ptr, k, j);
  20.             b = GetTickCount();
  21.             printf("MEM_set_val() test: %dms", b-a);
  22.             a = GetTickCount();
  23.             for(j = 0; j < LOOP; j++) for(k = 0; k < MEM_SIZE; k++) dummy = MEM_get_val(ptr, k);
  24. #pragma unused dummy
  25.             b = GetTickCount();
  26.             printf("MEM_get_val() test: %dms", b-a);
  27.         }
  28.         MEM_free(ptr);
  29.     }
  30.     return 1;
  31. }
  32.  
  33. public OnFilterScriptExit()
  34. {
  35.     return 1;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement