Advertisement
BigETI

y_malloc_benchmark2.pwn

Jan 20th, 2015
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.12 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_malloc>
  3.  
  4. #define MEM_SIZE    (1024)
  5. #define LOOP        (100000)
  6.  
  7. public OnFilterScriptInit()
  8. {
  9.     print("\n======================");
  10.     print("= y_malloc benchmark =");
  11.     print("======================\n");
  12.     new Alloc:ptr = malloc(MEM_SIZE), i, j, k, a, b, dummy, arr[MEM_SIZE];
  13.     if(ptr)
  14.     {
  15.         for(i = 0; i < 10; i++)
  16.         {
  17.             a = GetTickCount();
  18.             for(j = 0; j < LOOP; j++) for(k = 0; k < MEM_SIZE; k++) mset(ptr, k, j);
  19.             b = GetTickCount();
  20.             printf("mset() test: %dms", b-a);
  21.             a = GetTickCount();
  22.             for(j = 0; j < LOOP; j++) for(k = 0; k < MEM_SIZE; k++) dummy = mget(ptr, k);
  23. #pragma unused dummy
  24.             b = GetTickCount();
  25.             printf("mget() test: %dms", b-a);
  26.             a = GetTickCount();
  27.             for(j = 0; j < LOOP; j++) for(k = 0; k < MEM_SIZE; k++) msets(ptr, 0, arr);
  28.             b = GetTickCount();
  29.             printf("msets() test: %dms", b-a);
  30.             a = GetTickCount();
  31.             for(j = 0; j < LOOP; j++) for(k = 0; k < MEM_SIZE; k++) mgets(arr, sizeof arr, ptr, 0);
  32.             b = GetTickCount();
  33.             printf("mgets() test: %dms", b-a);
  34.         }
  35.         free(ptr);
  36.     }
  37.     return 1;
  38. }
  39.  
  40. public OnFilterScriptExit()
  41. {
  42.     return 1;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement