Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <YSI\y_malloc>
- #define MEM_SIZE (1024)
- #define LOOP (100000)
- public OnFilterScriptInit()
- {
- print("\n======================");
- print("= y_malloc benchmark =");
- print("======================\n");
- new Alloc:ptr = malloc(MEM_SIZE), i, j, k, a, b, dummy, arr[MEM_SIZE];
- if(ptr)
- {
- for(i = 0; i < 10; i++)
- {
- a = GetTickCount();
- for(j = 0; j < LOOP; j++) for(k = 0; k < MEM_SIZE; k++) mset(ptr, k, j);
- b = GetTickCount();
- printf("mset() test: %dms", b-a);
- a = GetTickCount();
- for(j = 0; j < LOOP; j++) for(k = 0; k < MEM_SIZE; k++) dummy = mget(ptr, k);
- #pragma unused dummy
- b = GetTickCount();
- printf("mget() test: %dms", b-a);
- a = GetTickCount();
- for(j = 0; j < LOOP; j++) for(k = 0; k < MEM_SIZE; k++) msets(ptr, 0, arr);
- b = GetTickCount();
- printf("msets() test: %dms", b-a);
- a = GetTickCount();
- for(j = 0; j < LOOP; j++) for(k = 0; k < MEM_SIZE; k++) mgets(arr, sizeof arr, ptr, 0);
- b = GetTickCount();
- printf("mgets() test: %dms", b-a);
- }
- free(ptr);
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement