diff --git a/[web]/performancebrowser/luaTiming.lua b/[web]/performancebrowser/luaTiming.lua
new file mode 100644
index 000000000..ae4c6facb
--- /dev/null
+++ b/[web]/performancebrowser/luaTiming.lua
@@ -0,0 +1,68 @@
+-- Lua time recordings config
+g_LuaTimingRecordings = {
+ Enabled = true,
+ Frequency = 5000, -- in milliseconds
+ HistoryLength = 100, -- number of records to keep
+ HighCPUResourcesAmount = 10, -- percentage threshold
+}
+
+-- Global variable to store high usage resources similar to IPB
+g_HighUsageResources = {}
+
+-- Date/time formatting function
+local function getDateTimeString()
+ local time = getRealTime()
+ local weekday = ({"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"})[time.weekday + 1]
+ -- Weekday, DD.MM.YYYY, hh:mm:ss
+ return ("%s, %02d.%02d.%d, %02d:%02d:%02d"):format(weekday, time.monthday, time.month + 1, time.year + 1900, time.hour, time.minute, time.second)
+end
+
+function getLuaTimingRecordings( queryFilterText )
+ local columns = {"Resource", "CPU Usage", "Recorded Time"}
+ local rows = {}
+
+ -- Get the global high usage resources if it exists
+ if g_HighUsageResources then
+ for i, recording in ipairs(g_HighUsageResources) do
+ local resourceName = recording[1]
+ local cpuUsage = recording[2]
+ local recordedTime = recording[3]
+
+ -- Apply filter if specified
+ if not queryFilterText or queryFilterText == "" or string.find(string.lower(resourceName), string.lower(queryFilterText), 1, true) then
+ table.insert(rows, {resourceName, cpuUsage, recordedTime})
+ end
+ end
+ end
+
+ return columns, rows, true
+end
+
+-- Save high CPU resources function (based on IPB alarm.lua)
+function saveHighCPUResources()
+ local columns, rows = getPerformanceStats("Lua timing")
+
+ if not rows then
+ return
+ end
+
+ for index, row in pairs(rows) do
+ local usageText = row[2]:gsub("[^0-9%.]", "")
+ local usage = math.floor(tonumber(usageText) or 0)
+
+ if (usage > g_LuaTimingRecordings.HighCPUResourcesAmount) then
+ -- Record this high usage to table
+ table.insert(g_HighUsageResources, 1, {row[1], row[2], getDateTimeString()})
+
+ -- Make sure it won't get too big
+ if #g_HighUsageResources > g_LuaTimingRecordings.HistoryLength then
+ table.remove(g_HighUsageResources, g_LuaTimingRecordings.HistoryLength)
+ end
+ end
+ end
+end
+
+-- Start monitoring timer
+if (g_LuaTimingRecordings.Enabled) then
+ setTimer(saveHighCPUResources, g_LuaTimingRecordings.Frequency, 0)
+end
\ No newline at end of file
diff --git a/[web]/performancebrowser/meta.xml b/[web]/performancebrowser/meta.xml
index 741f7e20e..02caa6302 100644
--- a/[web]/performancebrowser/meta.xml
+++ b/[web]/performancebrowser/meta.xml
@@ -1,6 +1,7 @@
+
diff --git a/[web]/performancebrowser/performancebrowser.lua b/[web]/performancebrowser/performancebrowser.lua
index 2161a37eb..bbfb38737 100644
--- a/[web]/performancebrowser/performancebrowser.lua
+++ b/[web]/performancebrowser/performancebrowser.lua
@@ -4,56 +4,8 @@
--
--
--- Lua time recordings config
-g_LuaTimingRecordings = {
- Enabled = true,
- Frequency = 2000, -- in milliseconds
- HistoryLength = 300, -- number of records to keep
- HighCPUResourcesAmount = 10, -- percentage threshold
-}
-
--- Global variable to store high usage resources similar to IPB
-g_HighUsageResources = {}
-
-- Browser update
function setQuery ( counter, user, target, category, options, filter, showClients )
local viewer = getViewer(user)
return viewer:setQuery ( counter, target, category, options, filter, showClients )
-end
-
--- Date/time formatting function
-local function getDateTimeString()
- local time = getRealTime()
- local weekday = ({"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"})[time.weekday + 1]
- -- Weekday, DD.MM.YYYY, hh:mm:ss
- return ("%s, %02d.%02d.%d, %02d:%02d:%02d"):format(weekday, time.monthday, time.month + 1, time.year + 1900, time.hour, time.minute, time.second)
-end
-
--- Save high CPU resources function (based on IPB alarm.lua)
-function saveHighCPUResources()
- local columns, rows = getPerformanceStats("Lua timing")
-
- if not rows then
- return
- end
-
- for index, row in pairs(rows) do
- local usageText = row[2]:gsub("[^0-9%.]", "")
- local usage = math.floor(tonumber(usageText) or 0)
-
- if (usage > g_LuaTimingRecordings.HighCPUResourcesAmount) then
- -- Record this high usage to table
- table.insert(g_HighUsageResources, 1, {row[1], row[2], getDateTimeString()})
-
- -- Make sure it won't get too big
- if #g_HighUsageResources > g_LuaTimingRecordings.HistoryLength then
- table.remove(g_HighUsageResources, g_LuaTimingRecordings.HistoryLength)
- end
- end
- end
-end
-
--- Start monitoring timer
-if (g_LuaTimingRecordings.Enabled) then
- setTimer(saveHighCPUResources, g_LuaTimingRecordings.Frequency, 0)
end
\ No newline at end of file
diff --git a/[web]/performancebrowser/performancebrowser_client.lua b/[web]/performancebrowser/performancebrowser_client.lua
index c87157b58..7289953de 100644
--- a/[web]/performancebrowser/performancebrowser_client.lua
+++ b/[web]/performancebrowser/performancebrowser_client.lua
@@ -30,7 +30,13 @@ addEventHandler('onClientRequestCategories', me,
addEvent('onClientRequestStats', true)
addEventHandler('onClientRequestStats', me,
function( username, queryCategoryName, queryOptionsText, queryFilterText )
+
+ if queryCategoryName == "Lua time recordings" then
+ local a, b = getLuaTimingRecordings( queryFilterText )
+ return triggerServerEvent( "onNotifyStats", resourceRoot, a, b, username, queryCategoryName, queryOptionsText, queryFilterText )
+ end
+
local a,b = getPerformanceStats( queryCategoryName, queryOptionsText, queryFilterText )
triggerServerEvent( "onNotifyStats", resourceRoot, a, b, username, queryCategoryName, queryOptionsText, queryFilterText )
end
-)
+)
\ No newline at end of file
diff --git a/[web]/performancebrowser/target.lua b/[web]/performancebrowser/target.lua
index c715289f2..309da04fe 100644
--- a/[web]/performancebrowser/target.lua
+++ b/[web]/performancebrowser/target.lua
@@ -69,12 +69,11 @@ end
--
---------------------------------------------------------------------------
function Target:getPerformanceStats( username, queryCategoryName, queryOptionsText, queryFilterText )
- -- Handle our custom Lua time recordings category
- if queryCategoryName == "Lua time recordings" then
- return self:getLuaTimingRecordings( queryFilterText )
- end
-
if self.bIsServer then
+ if queryCategoryName == "Lua time recordings" then
+ return getLuaTimingRecordings( queryFilterText )
+ end
+
local a, b = getPerformanceStats ( queryCategoryName, queryOptionsText, queryFilterText )
return a, b, true
else
@@ -158,33 +157,4 @@ addEventHandler('onNotifyStats', resourceRoot,
store.queryFilterText = queryFilterText
store.timeAdded = getTickCount()
end
-)
-
----------------------------------------------------------------------------
---
--- Target:getLuaTimingRecordings()
---
--- Get recorded high usage Lua timing data
---
----------------------------------------------------------------------------
-function Target:getLuaTimingRecordings( queryFilterText )
- local columns = {"Resource", "CPU Usage", "Recorded Time"}
- local rows = {}
-
- -- Get the global high usage resources if it exists
- if g_HighUsageResources then
- for i, recording in ipairs(g_HighUsageResources) do
- local resourceName = recording[1]
- local cpuUsage = recording[2]
- local recordedTime = recording[3]
-
- -- Apply filter if specified
- if not queryFilterText or queryFilterText == "" or string.find(string.lower(resourceName), string.lower(queryFilterText), 1, true) then
- table.insert(rows, {resourceName, cpuUsage, recordedTime})
- end
- end
- end
-
- return columns, rows, true
-end
-
+)
\ No newline at end of file
diff --git a/[web]/performancebrowser/viewer.lua b/[web]/performancebrowser/viewer.lua
index 4340c4bea..79cb9c563 100644
--- a/[web]/performancebrowser/viewer.lua
+++ b/[web]/performancebrowser/viewer.lua
@@ -155,7 +155,7 @@ function Viewer:getCategoriesRaw ()
local categories = {}
for _,row in ipairs(rowList) do
table.insert( categories, row[1] )
- if ( row[1] == "Lua timing" and target.bIsServer ) then -- Add our custom Lua time recordings category
+ if ( row[1] == "Lua timing" ) then -- Add our custom Lua time recordings category
table.insert( categories, "Lua time recordings" )
end
end