Skip to content

Commit 0c2719f

Browse files
committed
Moved profiler to its own module
1 parent 394c0e7 commit 0c2719f

File tree

9 files changed

+59
-54
lines changed

9 files changed

+59
-54
lines changed

lua/blobsprofiler/client/cl_blobsprofiler.lua

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ local function addDTreeNode(parentNode, nodeData, specialType, isRoot, varType,
925925
return childNode
926926
end
927927

928-
local function buildDTree(luaState, parentPanel, rvarType)
928+
local function buildDTree(luaState, parentPanel, rvarType, dataTableOverride)
929929
local dTree = vgui.Create("BP_DTree", parentPanel)
930930
dTree:Dock(FILL)
931931
--dTree:SetVisible(false)
@@ -939,7 +939,13 @@ local function buildDTree(luaState, parentPanel, rvarType)
939939
varType = subModuleSplit[2] -- ew
940940
end
941941

942-
local dataTable = blobsProfiler.GetDataTableForRealm(luaState, rvarType) or {}
942+
local dataTable
943+
944+
if dataTableOverride then
945+
dataTable = dataTableOverride
946+
else
947+
dataTable = blobsProfiler.GetDataTableForRealm(luaState, rvarType) or {}
948+
end
943949

944950
if varType == "Globals" then -- TODO: make this shit modular
945951
for key, value in pairs(dataTable) do
@@ -965,41 +971,6 @@ local function buildDTree(luaState, parentPanel, rvarType)
965971
blobsProfiler.Menu.TypeFolders[luaState][nodeData.special].nodeData = nodeData
966972
end
967973
end
968-
elseif varType == "Hooks" then
969-
for k, v in pairs(dataTable) do
970-
table.insert(rootNodes, {
971-
key = k,
972-
value = v
973-
})
974-
end
975-
elseif varType == "ConCommands" then
976-
for k, v in pairs(dataTable) do
977-
table.insert(rootNodes, {
978-
key = k,
979-
value = v
980-
})
981-
end
982-
elseif varType == "Files" then
983-
for k, v in pairs(dataTable) do
984-
table.insert(rootNodes, {
985-
key = k,
986-
value = v
987-
})
988-
end
989-
elseif varType == "Network" then
990-
for k, v in pairs(dataTable) do
991-
table.insert(rootNodes, {
992-
key = k,
993-
value = v
994-
})
995-
end
996-
elseif varType == "Timers" then
997-
for k, v in pairs(dataTable) do
998-
table.insert(rootNodes, {
999-
key = k,
1000-
value = v
1001-
})
1002-
end
1003974
elseif rvarType == "SQLite.Schema" then
1004975
if dataTable.Tables and dataTable.Indices then
1005976
table.insert(rootNodes, {
@@ -1012,6 +983,13 @@ local function buildDTree(luaState, parentPanel, rvarType)
1012983
value = blobsProfiler.TableSort.KeyAlphabetical(dataTable.Indices)
1013984
})
1014985
end
986+
else
987+
for k, v in pairs(dataTable) do
988+
table.insert(rootNodes, {
989+
key = k,
990+
value = v
991+
})
992+
end
1015993
end
1016994

1017995
if rvarType ~= "SQLite.Schema" then -- ewww
@@ -1033,11 +1011,11 @@ if blobsProfiler.Menu.MenuFrame && IsValid(blobsProfiler.Menu.MenuFrame) then
10331011
blobsProfiler.Menu.MenuFrame:Remove() -- kill on lua refresh
10341012
end
10351013

1036-
local function profileLog(realm, event)
1014+
--[[local function profileLog(realm, event)
10371015
local luaCallInfo = debug.getinfo(3, "fnS")
10381016
if not blobsProfiler.Client.Profile.Raw[luaCallInfo.func] then return end
10391017
print(event, luaCallInfo.name, luaCallInfo.func, luaCallInfo.source)
1040-
end
1018+
end]]
10411019

10421020
blobsProfiler.Tabs = {}
10431021
blobsProfiler.Tabs.Client = {}
@@ -1106,7 +1084,7 @@ concommand.Add("blobsprofiler", function(ply, cmd, args, argStr)
11061084
local tabMenu = vgui.Create( "DPropertySheet", blobsProfiler.Menu.MenuFrame)
11071085
tabMenu:Dock( FILL )
11081086

1109-
blobsProfiler.Menu.MenuFrame.ProfilerPanel = vgui.Create("DPanel", blobsProfiler.Menu.MenuFrame)
1087+
--[[blobsProfiler.Menu.MenuFrame.ProfilerPanel = vgui.Create("DPanel", blobsProfiler.Menu.MenuFrame)
11101088
local profilerPanel = blobsProfiler.Menu.MenuFrame.ProfilerPanel
11111089
profilerPanel:Dock(RIGHT)
11121090
profilerPanel:DockMargin(5, 10, 0, 0)
@@ -1126,7 +1104,7 @@ concommand.Add("blobsprofiler", function(ply, cmd, args, argStr)
11261104
startProfiling:SetTall(30)
11271105
startProfiling.DoClick = function()
11281106
debug.sethook(function(e) profileLog("Client", e) end, "cr")
1129-
end
1107+
end]]
11301108

11311109
local tabClient = vgui.Create("DPropertySheet", tabMenu)
11321110
tabMenu:AddSheet("Client", tabClient, "icon16/application.png")
@@ -1253,10 +1231,16 @@ concommand.Add("blobsprofiler", function(ply, cmd, args, argStr)
12531231

12541232
moduleTab.OnActiveTabChanged = function(s, pnlOld, pnlNew)
12551233
if blobsProfiler.Modules[moduleName].SubModules[pnlNew:GetText()].OnOpen then
1256-
blobsProfiler.Modules[moduleName].SubModules[pnlNew:GetText()].OnOpen(luaState)
1234+
local useTab
1235+
if luaState == "Client" then
1236+
useTab = blobsProfiler.Modules[moduleName].SubModules[pnlNew:GetText()].ClientTab
1237+
else
1238+
useTab = blobsProfiler.Modules[moduleName].SubModules[pnlNew:GetText()].ServerTab
1239+
end
1240+
blobsProfiler.Modules[moduleName].SubModules[pnlNew:GetText()].OnOpen(luaState, useTab)
12571241
end
12581242

1259-
if not blobsProfiler[luaState][moduleName][pnlNew:GetText()] then
1243+
if not blobsProfiler[luaState][moduleName] or not blobsProfiler[luaState][moduleName][pnlNew:GetText()] then
12601244
if blobsProfiler.Modules[moduleName].SubModules[pnlNew:GetText()].UpdateRealmData then
12611245
blobsProfiler.Modules[moduleName].SubModules[pnlNew:GetText()]:UpdateRealmData(luaState)
12621246
if luaState == "Server" then
@@ -1324,7 +1308,7 @@ concommand.Add("blobsprofiler", function(ply, cmd, args, argStr)
13241308

13251309
if pnlNew:GetText() == "Server" and blobsProfiler.Modules[subActiveTab:GetText()] and firstSubModule[subActiveTab:GetText()] then
13261310
if firstSubModule[subActiveTab:GetText()].data.OnOpen then
1327-
firstSubModule[subActiveTab:GetText()].data.OnOpen("Server")
1311+
firstSubModule[subActiveTab:GetText()].data.OnOpen("Server", firstSubModule[subActiveTab:GetText()].data.ServerTab)
13281312
end
13291313

13301314
if firstSubModule[subActiveTab:GetText()].data.UpdateRealmData then
@@ -1344,7 +1328,7 @@ concommand.Add("blobsprofiler", function(ply, cmd, args, argStr)
13441328
end
13451329

13461330
if blobsProfiler.Modules[pnlNew:GetText()].OnOpen then
1347-
blobsProfiler.Modules[pnlNew:GetText()].OnOpen("Client")
1331+
blobsProfiler.Modules[pnlNew:GetText()].OnOpen("Client", blobsProfiler.Modules[pnlNew:GetText()].ClientTab)
13481332
end
13491333
end
13501334

@@ -1358,12 +1342,12 @@ concommand.Add("blobsprofiler", function(ply, cmd, args, argStr)
13581342
end
13591343

13601344
if blobsProfiler.Modules[pnlNew:GetText()].OnOpen then
1361-
blobsProfiler.Modules[pnlNew:GetText()].OnOpen("Server")
1345+
blobsProfiler.Modules[pnlNew:GetText()].OnOpen("Server", blobsProfiler.Modules[pnlNew:GetText()].ServerTab)
13621346
end
13631347

13641348
if blobsProfiler.Modules[pnlNew:GetText()] and firstSubModule[pnlNew:GetText()] then
13651349
if firstSubModule[pnlNew:GetText()].data.OnOpen then
1366-
firstSubModule[pnlNew:GetText()].data.OnOpen("Server")
1350+
firstSubModule[pnlNew:GetText()].data.OnOpen("Server", firstSubModule[pnlNew:GetText()].data.ServerTab)
13671351
end
13681352
if firstSubModule[pnlNew:GetText()].data.UpdateRealmData then
13691353
if blobsProfiler.Server[pnlNew:GetText()][firstSubModule[pnlNew:GetText()].name] then return end

lua/blobsprofiler/shared/modules/bp_concommands.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
blobsProfiler.RegisterModule("ConCommands", {
22
Icon = "icon16/application_xp_terminal.png",
3-
OrderPriority = 3,
3+
OrderPriority = 4,
44
UpdateRealmData = function(luaState)
55
if luaState == "Client" then
66
local concmdTbl = concommand.GetTable()

lua/blobsprofiler/shared/modules/bp_files.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ end
5151

5252
blobsProfiler.RegisterModule("Files", {
5353
Icon = "icon16/folder_page.png",
54-
OrderPriority = 4,
54+
OrderPriority = 5,
5555
UpdateRealmData = function(luaState)
5656
if luaState == "Client" then
5757
local allFiles, newFiles = blobsProfiler.ScanGLoadedFiles()

lua/blobsprofiler/shared/modules/bp_hooks.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
blobsProfiler.RegisterModule("Hooks", {
22
Icon = "icon16/brick_add.png",
3-
OrderPriority = 2,
3+
OrderPriority = 3,
44
UpdateRealmData = function(luaState)
55
if luaState == "Client" then
66
local hooksTable = {}

lua/blobsprofiler/shared/modules/bp_lua.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ end
44

55
blobsProfiler.RegisterModule("Lua", {
66
Icon = "icon16/world.png",
7-
OrderPriority = 1,
7+
OrderPriority = 2,
88
})
99

1010
--[[local validTypes = {

lua/blobsprofiler/shared/modules/bp_network.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
blobsProfiler.RegisterModule("Network", {
22
Icon = "icon16/drive_network.png",
3-
OrderPriority = 5,
3+
OrderPriority = 6,
44
UpdateRealmData = function(luaState)
55
if luaState == "Client" then
66
local netRecieversData = {}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
blobsProfiler.RegisterModule("Profiling", {
2+
Icon = "icon16/hourglass.png",
3+
OrderPriority = 1
4+
})
5+
6+
blobsProfiler.RegisterSubModule("Profiling", "Targets", {
7+
Icon = "icon16/book_addresses.png",
8+
OrderPriority = 1,
9+
OnOpen = function(luaState, parentPanel)
10+
print("profiling on open!", luaState, parentPanel)
11+
local profilerData = table.Copy(blobsProfiler.Client.Profile or {})
12+
profilerData.Raw = nil -- we dont need to display this
13+
14+
blobsProfiler.buildDTree(luaState, parentPanel, "Profiling.Targets", profilerData)
15+
end
16+
})
17+
18+
blobsProfiler.RegisterSubModule("Profiling", "Results", {
19+
Icon = "icon16/chart_bar.png",
20+
OrderPriority = 2
21+
})

lua/blobsprofiler/shared/modules/bp_sqlite.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
blobsProfiler.RegisterModule("SQLite", {
22
Icon = "icon16/database.png",
3-
OrderPriority = 7
3+
OrderPriority = 8
44
})
55

66
local function buildSQLiteSchemaTable()

lua/blobsprofiler/shared/modules/bp_timers.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ end
1414

1515
blobsProfiler.RegisterModule("Timers", {
1616
Icon = "icon16/clock.png",
17-
OrderPriority = 6,
17+
OrderPriority = 7,
1818
UpdateRealmData = function(luaState)
1919
if luaState == "Client" then
2020
-- why dont we just set it straight away ffs

0 commit comments

Comments
 (0)