Radioqueue Profiler

This commit is contained in:
Frank 2020-08-22 21:18:12 +02:00
parent f823fc6ee0
commit f30c66424c
2 changed files with 27 additions and 16 deletions

View File

@ -17,7 +17,7 @@
--
-- @type RADIOQUEUE
-- @field #string ClassName Name of the class "RADIOQUEUE".
-- @field #boolean Debug Debug mode. More info.
-- @field #boolean Debugmode Debug mode. More info.
-- @field #string lid ID for dcs.log.
-- @field #number frequency The radio frequency in Hz.
-- @field #number modulation The radio modulation. Either radio.modulation.AM or radio.modulation.FM.
@ -38,7 +38,7 @@
-- @extends Core.Base#BASE
RADIOQUEUE = {
ClassName = "RADIOQUEUE",
Debug = nil,
Debugmode = nil,
lid = nil,
frequency = nil,
modulation = nil,
@ -55,7 +55,7 @@ RADIOQUEUE = {
power = nil,
numbers = {},
checking = nil,
schedonce = nil,
schedonce = false,
}
--- Radio queue transmission data.
@ -375,8 +375,10 @@ function RADIOQUEUE:Broadcast(transmission)
sender:SetCommand(commandTransmit)
-- Debug message.
local text=string.format("file=%s, freq=%.2f MHz, duration=%.2f sec, subtitle=%s", filename, self.frequency/1000000, transmission.duration, transmission.subtitle or "")
MESSAGE:New(text, 2, "RADIOQUEUE "..self.alias):ToAllIf(self.Debug)
if self.Debugmode then
local text=string.format("file=%s, freq=%.2f MHz, duration=%.2f sec, subtitle=%s", filename, self.frequency/1000000, transmission.duration, transmission.subtitle or "")
MESSAGE:New(text, 2, "RADIOQUEUE "..self.alias):ToAll()
end
else
@ -388,10 +390,7 @@ function RADIOQUEUE:Broadcast(transmission)
-- Try to get positon from sender unit/static.
if self.sendername then
local coord=self:_GetRadioSenderCoord()
if coord then
vec3=coord:GetVec3()
end
vec3=self:_GetRadioSenderCoord()
end
-- Try to get fixed positon.
@ -408,8 +407,10 @@ function RADIOQUEUE:Broadcast(transmission)
trigger.action.radioTransmission(filename, vec3, self.modulation, false, self.frequency, self.power)
-- Debug message.
local text=string.format("file=%s, freq=%.2f MHz, duration=%.2f sec, subtitle=%s", filename, self.frequency/1000000, transmission.duration, transmission.subtitle or "")
MESSAGE:New(string.format(text, filename, transmission.duration, transmission.subtitle or ""), 5, "RADIOQUEUE "..self.alias):ToAllIf(self.Debug)
if self.Debugmode then
local text=string.format("file=%s, freq=%.2f MHz, duration=%.2f sec, subtitle=%s", filename, self.frequency/1000000, transmission.duration, transmission.subtitle or "")
MESSAGE:New(string.format(text, filename, transmission.duration, transmission.subtitle or ""), 5, "RADIOQUEUE "..self.alias):ToAll()
end
end
end
@ -532,6 +533,7 @@ function RADIOQUEUE:_GetRadioSender()
-- Try the general default.
if self.sendername then
-- First try to find a unit
sender=UNIT:FindByName(self.sendername)
@ -547,7 +549,7 @@ end
--- Get unit from which we want to transmit a radio message. This has to be an aircraft for subtitles to work.
-- @param #RADIOQUEUE self
-- @return Core.Point#COORDINATE Coordinate of the sender unit.
-- @return DCS#Vec3 Vector 3D.
function RADIOQUEUE:_GetRadioSenderCoord()
local vec3=nil
@ -560,7 +562,7 @@ function RADIOQUEUE:_GetRadioSenderCoord()
-- Check that sender is alive and an aircraft.
if sender and sender:IsAlive() then
return sender:GetCoordinate()
return sender:GetVec3()
end
-- Now try a static.
@ -568,7 +570,7 @@ function RADIOQUEUE:_GetRadioSenderCoord()
-- Check that sender is alive and an aircraft.
if sender then
return sender:GetCoordinate()
return sender:GetVec3()
end
end

View File

@ -75,11 +75,17 @@
--
-- It will tell you how many times a function was called in total, how many times per second, how much time in total and the percentage of time.
--
-- If you only want output for functions that are called more than X times per second, you can set
-- If you only want output for functions that are called more than *X* times per second, you can set
--
-- PROFILER.ThreshCPS=1.5
--
-- With this setting, only functions which are called more than 1.5 times per second are displayed.
-- With this setting, only functions which are called more than 1.5 times per second are displayed. The default setting is PROFILER.ThreshCPS=0.0 (no threshold).
--
-- Furthermore, you can limit the output for functions that consumed a certain amount of CPU time in total by
--
-- PROFILER.ThreshTtot=0.005
--
-- With this setting, which is also the default, only functions which in total used more than 5 milliseconds CPU time.
--
-- @field #PROFILER
PROFILER = {
@ -452,6 +458,9 @@ function PROFILER.showInfo(runTimeGame, runTimeOS)
PROFILER._flog(f,string.format("* Total functions = %d", #t))
PROFILER._flog(f,string.format("* Total func calls = %d", Calls))
PROFILER._flog(f,"")
PROFILER._flog(f,string.format("* Calls per second threshold = %.3f/sec", PROFILER.ThreshCPS))
PROFILER._flog(f,string.format("* Total func time threshold = %.3f/sec", PROFILER.ThreshTtot))
PROFILER._flog(f,"")
PROFILER._flog(f,"************************************************************************************************************************")
PROFILER._flog(f,"")
PROFILER.showTable(t, f, runTimeGame)