Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1.  
  2. local mode = 0 -- 0 is ClassName, 1 is Name, 2 is parent, 3 is FullName
  3. local printRate = 60 -- set to math.huge to disable
  4. -- You can add a BindableEvent named PrintStats to this script and fire it to print stats
  5.  
  6. ---
  7.  
  8. local changes = {}
  9. local GetFullName = workspace.GetFullName
  10. game.ItemChanged:connect(function(item, prop)
  11. local n = ""
  12. if mode == 2 then
  13. pcall(function()
  14. n = n..item.Parent.Name.."."
  15. end)
  16. end
  17. pcall(function() -- Sometimes this will fire on RobloxLocked instances!
  18. n =
  19. (mode == 0 and item.ClassName)
  20. or (mode <= 2 and tostring(item)) -- tostring works on RobloxLocked instances.
  21. or (mode == 3 and GetFullName(item))
  22. end)
  23. n = n.."."..prop
  24. changes[n] = (changes[n] or 0) + 1
  25. end)
  26. local adds = {}
  27. game.DescendantAdded:connect(function(item)
  28. local n = ""
  29. if mode == 2 then
  30. pcall(function()
  31. n = n..item.Parent.Name.."."
  32. end)
  33. end
  34. pcall(function() -- Sometimes this will fire on RobloxLocked instances!
  35. n =
  36. (mode == 0 and item.ClassName)
  37. or (mode <= 2 and tostring(item)) -- tostring works on RobloxLocked instances.
  38. or (mode == 3 and GetFullName(item))
  39. end)
  40. adds[n] = (adds[n] or 0) + 1
  41. end)
  42. local removes = {}
  43. game.DescendantRemoving:connect(function(item)
  44. local n = ""
  45. if mode == 2 then
  46. pcall(function()
  47. n = n..item.Parent.Name.."."
  48. end)
  49. end
  50. pcall(function() -- Sometimes this will fire on RobloxLocked instances!
  51. n =
  52. (mode == 0 and item.ClassName)
  53. or (mode <= 2 and tostring(item)) -- tostring works on RobloxLocked instances.
  54. or (mode == 3 and GetFullName(item))
  55. end)
  56. removes[n] = (removes[n] or 0) + 1
  57. end)
  58.  
  59. local frms = 0
  60.  
  61. game:GetService("RunService"):BindToRenderStep("logFrames", Enum.RenderPriority.First.Value, function()
  62. frms = frms + 1
  63. end)
  64.  
  65. local printFunc = function()
  66. do
  67. print(("\n"):rep(6).."Adds:")
  68. local t = {}
  69. local maxNameLength = 0
  70. for k, v in next, adds do
  71. maxNameLength = math.max(maxNameLength, #k)
  72. t[#t + 1] = {k, v}
  73. end
  74. table.sort(t, function(a, b)
  75. return a[2] < b[2]
  76. end)
  77. for i = 1, #t do
  78. local n = t[i][1]
  79. n = n..(" "):rep(maxNameLength - #n)
  80. print(" - ", n..": "..t[i][2].."; "..(math.floor(t[i][2]/frms*10)/10).." per frame")
  81. end
  82. end
  83. do
  84. print(("\n"):rep(6).."Removes:")
  85. local t = {}
  86. local maxNameLength = 0
  87. for k, v in next, removes do
  88. maxNameLength = math.max(maxNameLength, #k)
  89. t[#t + 1] = {k, v}
  90. end
  91. table.sort(t, function(a, b)
  92. return a[2] < b[2]
  93. end)
  94. for i = 1, #t do
  95. local n = t[i][1]
  96. n = n..(" "):rep(maxNameLength - #n)
  97. print(" - ", n..": "..t[i][2].."; "..(math.floor(t[i][2]/frms*10)/10).." per frame")
  98. end
  99. end
  100. do
  101. print(("\n"):rep(6).."Changes:")
  102. local t = {}
  103. local maxNameLength = 0
  104. for k, v in next, changes do
  105. maxNameLength = math.max(maxNameLength, #k)
  106. t[#t + 1] = {k, v}
  107. end
  108. table.sort(t, function(a, b)
  109. return a[2] < b[2]
  110. end)
  111. for i = 1, #t do
  112. local n = t[i][1]
  113. n = n..(" "):rep(maxNameLength - #n)
  114. print(" - ", n..": "..t[i][2].."; "..(math.floor(t[i][2]/frms*10)/10).." per frame")
  115. end
  116. end
  117. end
  118.  
  119. if script:FindFirstChild("PrintStats") then
  120. script.PrintStats.Event:connect(printFunc)
  121. end
  122.  
  123. while wait(printRate) do
  124. printFunc()
  125. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement