Advertisement
BigETI

memory_benchmark2.pwn

Jan 20th, 2015
560
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.23 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, arr[MEM_SIZE];
  14.     if(ptr)
  15.     {
  16.         for(i = 0; i < 10; 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.             a = GetTickCount();
  28.             for(j = 0; j < LOOP; j++) for(k = 0; k < MEM_SIZE; k++) MEM_set_arr(ptr, _, arr);
  29.             b = GetTickCount();
  30.             printf("MEM_set_arr() test: %dms", b-a);
  31.             a = GetTickCount();
  32.             for(j = 0; j < LOOP; j++) for(k = 0; k < MEM_SIZE; k++) MEM_set_arr(ptr, _, arr);
  33.             b = GetTickCount();
  34.             printf("MEM_get_arr() test: %dms", b-a);
  35.         }
  36.         MEM_free(ptr);
  37.     }
  38.     return 1;
  39. }
  40.  
  41. public OnFilterScriptExit()
  42. {
  43.     return 1;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement