Advertisement
hschlichting2003

BNCHMRK | A,B in pairs

Feb 10th, 2024
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. Testing to see if ommitting the a in for a,b in pairs will actually make a difference.
  2.  
  3. Test given:
  4. Folder with 1000 children, renaming them each loop.
  5.  
  6. Test result:
  7. WITHOUT the a in a,b | Average time taken: 24641 nanoseconds - Client - SpeedBenchmark:23
  8. WITH the a in a,b | Average time taken: 24351 nanoseconds - Client - SpeedBenchmark:23
  9.  
  10. Test code:
  11. local replicatedStorage = game.ReplicatedStorage
  12.  
  13. local speed = require(replicatedStorage.SpeedBenchmark)
  14.  
  15. local avg = {}
  16.  
  17. for i = 1000, 1, -1 do
  18. local start = speed:placeStart()
  19.  
  20. local name = 1
  21.  
  22. for e, a in pairs(replicatedStorage.Children:GetChildren()) do
  23. if a then
  24. a.Name = tostring(name)
  25. end
  26.  
  27. name = name + 1
  28. end
  29.  
  30. speed:placeEnd(start, avg)
  31. end
  32.  
  33. avg = {}
  34.  
  35. for i = 1000, 1, -1 do
  36. local start = speed:placeStart()
  37.  
  38. local name = 1
  39.  
  40. for _, a in pairs(replicatedStorage.Children:GetChildren()) do
  41. if a then
  42. a.Name = tostring(name)
  43. end
  44.  
  45. name = name + 1
  46. end
  47.  
  48. speed:placeEnd(start, avg)
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement