Flleeppyy

length(list) over list.len.dm

Jul 25th, 2025
732
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 2.27 KB | None | 0 0
  1. // This run, in coderbus: https://discord.com/channels/484170914754330625/487268744419344384/1398185168891805758
  2.  
  3. /*
  4. Warning: "shell none" command in the profile file is done by default; the command will be deprecated
  5. Fri Jul 25 08:08:38 2025
  6. World opened on network port 34013.
  7. Welcome BYOND! (5.0 Public Version 516.1661)
  8. normal_list.len got 1249587 iterations in 0.5 seconds!
  9. length(normal list) got 1253465 iterations in 0.5 seconds!
  10. length(contents) got 788957 iterations in 0.5 seconds!
  11. contents list.len got 675388 iterations in 0.5 seconds!
  12. length(txt string) got 1230861 iterations in 0.5 seconds!
  13. The BYOND hub reports that port 34013 is not reachable.
  14. */
  15.  
  16. // BENCHMARK CODE - from coderbus https://discord.com/channels/484170914754330625/487268744419344384/1005309051791491193
  17. #define BENCHMARK_RESET iterations = 0; end_time = world.timeofday + duration;
  18. #define BENCHMARK_LOOP BENCHMARK_RESET; while(world.timeofday < end_time)
  19. #define BENCHMARK_MESSAGE(msg) world.log << "[msg] got [iterations] iterations in [seconds] seconds!"; BENCHMARK_RESET
  20. #define SECONDS *10
  21.  
  22. /atom/movable
  23.     var/list/normal_list = list()
  24.     var/txt = ""
  25.  
  26. /world
  27.     loop_checks = FALSE
  28.  
  29. /proc/main(seconds = 0.5)
  30.     var/duration = seconds SECONDS
  31.     var/iterations = 0
  32.     var/end_time = 0
  33.  
  34.     var/atom/movable/thingy = new()
  35.  
  36.     for(var/i in 1 to 100)
  37.         if(prob(50))
  38.             new/atom/movable(thingy)
  39.         else
  40.             new/mob(thingy)
  41.         thingy.normal_list += i
  42.         thingy.txt = "[thingy.txt]A"
  43.  
  44.     BENCHMARK_LOOP
  45.         var/x = thingy.normal_list.len
  46.         var/y = x + 1
  47.         iterations++
  48.  
  49.     BENCHMARK_MESSAGE("normal_list.len")
  50.  
  51.     BENCHMARK_LOOP
  52.         var/x = length(thingy.normal_list)
  53.         var/y = x + 1
  54.         iterations++
  55.  
  56.     BENCHMARK_MESSAGE("length(normal list)")
  57.  
  58.     BENCHMARK_LOOP
  59.         var/x = length(thingy.contents)
  60.         var/y = x + 1
  61.         iterations++
  62.  
  63.     BENCHMARK_MESSAGE("length(contents)")
  64.  
  65.     BENCHMARK_LOOP
  66.         var/x = thingy.contents.len
  67.         var/y = x + 1
  68.         iterations++
  69.  
  70.     BENCHMARK_MESSAGE("contents list.len")
  71.  
  72.     BENCHMARK_LOOP
  73.         var/x = length(thingy.txt)
  74.         var/y = x + 1
  75.         iterations++
  76.  
  77.     BENCHMARK_MESSAGE("length(txt string)")
Advertisement
Add Comment
Please, Sign In to add comment