Created
July 27, 2016 02:35
-
-
Save Corecii/55b39e3e349e6677b9f03f9e0adf9a84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local mode = 0 -- 0 is ClassName, 1 is Name, 2 is parent, 3 is FullName | |
local printRate = 60 -- set to math.huge to disable | |
-- You can add a BindableEvent named PrintStats to this script and fire it to print stats | |
--- | |
local changes = {} | |
local GetFullName = workspace.GetFullName | |
game.ItemChanged:connect(function(item, prop) | |
local n = "" | |
if mode == 2 then | |
pcall(function() | |
n = n..item.Parent.Name.."." | |
end) | |
end | |
pcall(function() -- Sometimes this will fire on RobloxLocked instances! | |
n = | |
(mode == 0 and item.ClassName) | |
or (mode <= 2 and tostring(item)) -- tostring works on RobloxLocked instances. | |
or (mode == 3 and GetFullName(item)) | |
end) | |
n = n.."."..prop | |
changes[n] = (changes[n] or 0) + 1 | |
end) | |
local adds = {} | |
game.DescendantAdded:connect(function(item) | |
local n = "" | |
if mode == 2 then | |
pcall(function() | |
n = n..item.Parent.Name.."." | |
end) | |
end | |
pcall(function() -- Sometimes this will fire on RobloxLocked instances! | |
n = | |
(mode == 0 and item.ClassName) | |
or (mode <= 2 and tostring(item)) -- tostring works on RobloxLocked instances. | |
or (mode == 3 and GetFullName(item)) | |
end) | |
adds[n] = (adds[n] or 0) + 1 | |
end) | |
local removes = {} | |
game.DescendantRemoving:connect(function(item) | |
local n = "" | |
if mode == 2 then | |
pcall(function() | |
n = n..item.Parent.Name.."." | |
end) | |
end | |
pcall(function() -- Sometimes this will fire on RobloxLocked instances! | |
n = | |
(mode == 0 and item.ClassName) | |
or (mode <= 2 and tostring(item)) -- tostring works on RobloxLocked instances. | |
or (mode == 3 and GetFullName(item)) | |
end) | |
removes[n] = (removes[n] or 0) + 1 | |
end) | |
local frms = 0 | |
game:GetService("RunService"):BindToRenderStep("logFrames", Enum.RenderPriority.First.Value, function() | |
frms = frms + 1 | |
end) | |
local printFunc = function() | |
do | |
print(("\n"):rep(6).."Adds:") | |
local t = {} | |
local maxNameLength = 0 | |
for k, v in next, adds do | |
maxNameLength = math.max(maxNameLength, #k) | |
t[#t + 1] = {k, v} | |
end | |
table.sort(t, function(a, b) | |
return a[2] < b[2] | |
end) | |
for i = 1, #t do | |
local n = t[i][1] | |
n = n..(" "):rep(maxNameLength - #n) | |
print(" - ", n..": "..t[i][2].."; "..(math.floor(t[i][2]/frms*10)/10).." per frame") | |
end | |
end | |
do | |
print(("\n"):rep(6).."Removes:") | |
local t = {} | |
local maxNameLength = 0 | |
for k, v in next, removes do | |
maxNameLength = math.max(maxNameLength, #k) | |
t[#t + 1] = {k, v} | |
end | |
table.sort(t, function(a, b) | |
return a[2] < b[2] | |
end) | |
for i = 1, #t do | |
local n = t[i][1] | |
n = n..(" "):rep(maxNameLength - #n) | |
print(" - ", n..": "..t[i][2].."; "..(math.floor(t[i][2]/frms*10)/10).." per frame") | |
end | |
end | |
do | |
print(("\n"):rep(6).."Changes:") | |
local t = {} | |
local maxNameLength = 0 | |
for k, v in next, changes do | |
maxNameLength = math.max(maxNameLength, #k) | |
t[#t + 1] = {k, v} | |
end | |
table.sort(t, function(a, b) | |
return a[2] < b[2] | |
end) | |
for i = 1, #t do | |
local n = t[i][1] | |
n = n..(" "):rep(maxNameLength - #n) | |
print(" - ", n..": "..t[i][2].."; "..(math.floor(t[i][2]/frms*10)/10).." per frame") | |
end | |
end | |
end | |
if script:FindFirstChild("PrintStats") then | |
script.PrintStats.Event:connect(printFunc) | |
end | |
while wait(printRate) do | |
printFunc() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment