nb109

Untitled

Aug 30th, 2020
257
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Script assets have changed for v2.3.0 see
  2. // https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information
  3. function Performance(numloops) {
  4.     gml_pragma("forceinline");
  5.     gml_pragma("UnityBuild", "true");
  6.     gml_release_mode(true);
  7.     randomize();
  8.  
  9.     var __numLoops = numloops;
  10.     var __i = 0;
  11.     var __strOut = ""
  12.  
  13.     __strOut += "\n##### ARRAY #####\n\n"
  14.     ////////////////////////////////////////////
  15.     // Array Uninitialized
  16.     var __label = "FILLING ARRAY (UNINITIALIZED)";
  17.     var __arr1 = [];
  18.     var __start = get_timer();
  19.  
  20.     for (__i = 0; __i < __numLoops; __i++) {
  21.       __arr1[ __i ] = random(10000);
  22.     }
  23.  
  24.     var __end = get_timer();
  25.     var __result = (__end - __start)
  26.     __strOut += __label + ": " + string(__result) + "\n"
  27.    
  28.     ////////////////////////////////////////////
  29.     // Array Initialized
  30.     var __label = "FILLING ARRAY (INITIALIZED)";
  31.     var __arr2 = array_create(__numLoops);
  32.     var __start = get_timer();
  33.  
  34.     for (__i = 0; __i < __numLoops; __i++) {
  35.       __arr2[ __i ] = random(10000);
  36.     }
  37.  
  38.     var __end = get_timer();
  39.     var __result = (__end - __start)
  40.     __strOut += __label + ": " + string(__result) + "\n"
  41.    
  42.     ////////////////////////////////////////////
  43.     // Array Read
  44.     var __label = "READING ARRAY";
  45.     var __dummy;
  46.     var __start = get_timer();
  47.  
  48.     for (__i = 0; __i < __numLoops; __i++) {
  49.       __dummy = __arr2[ __i ]
  50.     }
  51.  
  52.     var __end = get_timer();
  53.     var __result = (__end - __start)
  54.     __strOut += __label + ": " + string(__result) + "\n"
  55.    
  56.     ////////////////////////////////////////////
  57.     // List fill (UNINITIALIZED)
  58.     __strOut += "\n##### LIST #####\n\n"
  59.    
  60.     var __label = "FILLING LIST (UNINITIALIZED)";
  61.     var __ls1 = ds_list_create();
  62.     var __start = get_timer();
  63.  
  64.     for (__i = 0; __i < __numLoops; __i++) {
  65.       __ls1[| __i] = random(10000)
  66.     }
  67.  
  68.     var __end = get_timer();
  69.     var __result = (__end - __start)
  70.     __strOut += __label + ": " + string(__result) + "\n"
  71.    
  72.     ////////////////////////////////////////////
  73.     // List fill (BACKWARDS)
  74.    
  75.     var __label = "FILLING LIST (INITIALIZED)";
  76.     var __ls2 = ds_list_create();
  77.     var __start = get_timer();
  78.  
  79.     for (__i = __numLoops - 1; __i >= 0; __i--) {
  80.       __ls2[| __i] = random(10000)
  81.     }
  82.     var __end = get_timer();
  83.     var __result = (__end - __start)
  84.     __strOut += __label + ": " + string(__result) + "\n"
  85.    
  86.     ////////////////////////////////////////////
  87.     // List Read
  88.     var __label = "READING LIST";
  89.     var __dummy;
  90.     var __start = get_timer();
  91.  
  92.     for (__i = 0; __i < __numLoops; __i++) {
  93.       __dummy = __ls1[| __i]
  94.     }
  95.  
  96.     var __end = get_timer();
  97.     var __result = (__end - __start)
  98.     __strOut += __label + ": " + string(__result) + "\n"
  99.    
  100.     ////////////////////////////////////////////
  101.     // Grid Fill
  102.     __strOut += "\n##### GRID #####\n\n"
  103.    
  104.     var __label = "FILLING GRID";
  105.     var __gr = ds_grid_create(1, __numLoops)
  106.     var __start = get_timer();
  107.  
  108.     for (__i = 0; __i < __numLoops; __i++) {
  109.       ds_grid_set(__gr, 0, __i, random(10000))
  110.     }
  111.  
  112.     var __end = get_timer();
  113.     var __result = (__end - __start)
  114.     __strOut += __label + ": " + string(__result) + "\n"   
  115.  
  116.     ////////////////////////////////////////////
  117.     // Grid Read
  118.     var __label = "READING GRID";
  119.     var __dummy;
  120.     var __start = get_timer();
  121.  
  122.     for (__i = 0; __i < __numLoops; __i++) {
  123.       __dummy = __gr[# 0, __i]
  124.     }
  125.  
  126.     var __end = get_timer();
  127.     var __result = (__end - __start)
  128.     __strOut += __label + ": " + string(__result) + "\n"
  129.    
  130.     ////////////////////////////////////////////
  131.     // Map Fill
  132.     __strOut += "\n##### MAP #####\n\n"
  133.    
  134.     var __label = "FILLING MAP";
  135.     var __mp = ds_map_create()
  136.     var __start = get_timer();
  137.  
  138.     for (__i = 0; __i < __numLoops; __i++) {
  139.       ds_map_add(__mp, __i, random(10000))
  140.     }
  141.  
  142.     var __end = get_timer();
  143.     var __result = (__end - __start)
  144.     __strOut += __label + ": " + string(__result) + "\n"
  145.    
  146.     ////////////////////////////////////////////
  147.     // Map Read
  148.    
  149.     var __label = "READING MAP";
  150.     var __dummy;
  151.     var __mp = ds_map_create();
  152.     var __start = get_timer();
  153.  
  154.     for (__i = 0; __i < __numLoops; __i++) {
  155.       __dummy = __mp[? __i]
  156.     }
  157.  
  158.     var __end = get_timer();
  159.     var __result = (__end - __start)
  160.     __strOut += __label + ": " + string(__result) + "\n"   
  161.    
  162.     show_message(__strOut);
  163. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×