cleanup stale tests, profiling reports

This commit is contained in:
Michael Freno
2025-11-20 11:36:41 -05:00
parent 32009185e9
commit d0357672db
31 changed files with 994 additions and 446 deletions

View File

@@ -324,7 +324,7 @@ function Element.new(props)
-- Validate property combinations: passwordMode disables multiline
if self.passwordMode and props.multiline then
Element._ErrorHandler.warn("Element", "passwordMode is enabled, multiline will be disabled")
Element._ErrorHandler:warn("Element", "passwordMode is enabled, multiline will be disabled")
self.multiline = false
elseif self.passwordMode then
self.multiline = false
@@ -710,7 +710,7 @@ function Element.new(props)
-- Pixel units
self.textSize = value
else
Element._ErrorHandler.error(
Element._ErrorHandler:error(
"Element",
string.format("Unknown textSize unit '%s'. Valid units: px, %%, vw, vh, ew, eh. Or use presets: xs, sm, md, lg, xl, xxl, 2xl, 3xl, 4xl", unit)
)
@@ -718,7 +718,7 @@ function Element.new(props)
else
-- Validate pixel textSize value
if props.textSize <= 0 then
Element._ErrorHandler.error("Element", "textSize must be greater than 0, got: " .. tostring(props.textSize))
Element._ErrorHandler:error("Element", "textSize must be greater than 0, got: " .. tostring(props.textSize))
end
-- Pixel textSize value
@@ -2883,7 +2883,7 @@ function Element:_checkPerformanceWarnings()
-- Check hierarchy depth
local depth = self:getHierarchyDepth()
if depth >= 15 then
Performance:logWarning(
Element._Performance:logWarning(
string.format("hierarchy_depth_%s", self.id),
"Element",
string.format("Element hierarchy depth is %d levels for element '%s'", depth, self.id or "unnamed"),
@@ -2896,7 +2896,7 @@ function Element:_checkPerformanceWarnings()
if not self.parent then
local totalElements = self:countElements()
if totalElements >= 1000 then
Performance:logWarning(
Element._Performance:logWarning(
"element_count_high",
"Element",
string.format("UI contains %d+ elements", totalElements),
@@ -2926,7 +2926,7 @@ function Element:_trackActiveAnimations()
local animCount = self:_countActiveAnimations()
if animCount >= 50 then
Performance:logWarning(
Element._Performance:logWarning(
"animation_count_high",
"Element",
string.format("%d+ animations running simultaneously", animCount),
@@ -3032,13 +3032,13 @@ function Element:setTransition(property, config)
end
if type(config) ~= "table" then
Element._ErrorHandler.warn("Element", "setTransition() requires a config table. Using default config.")
Element._ErrorHandler:warn("Element", "setTransition() requires a config table. Using default config.")
config = {}
end
-- Validate config
if config.duration and (type(config.duration) ~= "number" or config.duration < 0) then
Element._ErrorHandler.warn("Element", "transition duration must be a non-negative number. Using 0.3 seconds.")
Element._ErrorHandler:warn("Element", "transition duration must be a non-negative number. Using 0.3 seconds.")
config.duration = 0.3
end
@@ -3056,7 +3056,7 @@ end
---@param properties table Array of property names
function Element:setTransitionGroup(groupName, config, properties)
if type(properties) ~= "table" then
Element._ErrorHandler.warn("Element", "setTransitionGroup() requires a properties array. No transitions set.")
Element._ErrorHandler:warn("Element", "setTransitionGroup() requires a properties array. No transitions set.")
return
end

View File

@@ -30,7 +30,7 @@ function ImageRenderer.calculateFit(imageWidth, imageHeight, boundsWidth, bounds
objectPosition = objectPosition or "center center"
if imageWidth <= 0 or imageHeight <= 0 or boundsWidth <= 0 or boundsHeight <= 0 then
ErrorHandler.error("ImageRenderer", "VAL_002", "Dimensions must be positive", {
ErrorHandler:error("ImageRenderer", "VAL_002", "Dimensions must be positive", {
imageWidth = imageWidth,
imageHeight = imageHeight,
boundsWidth = boundsWidth,
@@ -116,7 +116,7 @@ function ImageRenderer.calculateFit(imageWidth, imageHeight, boundsWidth, bounds
return ImageRenderer.calculateFit(imageWidth, imageHeight, boundsWidth, boundsHeight, "contain", objectPosition)
end
else
ErrorHandler.warn("ImageRenderer", "VAL_007", string.format("Invalid fit mode: '%s'. Must be one of: fill, contain, cover, scale-down, none", tostring(fitMode)), {
ErrorHandler:warn("ImageRenderer", "VAL_007", string.format("Invalid fit mode: '%s'. Must be one of: fill, contain, cover, scale-down, none", tostring(fitMode)), {
fitMode = fitMode,
fallback = "fill"
})
@@ -362,7 +362,7 @@ function ImageRenderer.drawTiled(image, x, y, width, height, repeatMode, opacity
end
end
else
ErrorHandler.warn("ImageRenderer", "VAL_007", string.format("Invalid repeat mode: '%s'. Using 'no-repeat'", tostring(repeatMode)), {
ErrorHandler:warn("ImageRenderer", "VAL_007", string.format("Invalid repeat mode: '%s'. Using 'no-repeat'", tostring(repeatMode)), {
repeatMode = repeatMode,
fallback = "no-repeat"
})

View File

@@ -27,11 +27,11 @@ end
---@return love.ImageData -- Scaled image data
function ImageScaler.scaleNearest(sourceImageData, srcX, srcY, srcW, srcH, destW, destH)
if not sourceImageData then
ErrorHandler.error("ImageScaler", "VAL_001", "Source ImageData cannot be nil")
ErrorHandler:error("ImageScaler", "VAL_001", "Source ImageData cannot be nil")
end
if srcW <= 0 or srcH <= 0 or destW <= 0 or destH <= 0 then
ErrorHandler.warn("ImageScaler", "VAL_002", "Dimensions must be positive", {
ErrorHandler:warn("ImageScaler", "VAL_002", "Dimensions must be positive", {
srcW = srcW,
srcH = srcH,
destW = destW,
@@ -95,11 +95,11 @@ end
---@return love.ImageData -- Scaled image data
function ImageScaler.scaleBilinear(sourceImageData, srcX, srcY, srcW, srcH, destW, destH)
if not sourceImageData then
ErrorHandler.error("ImageScaler", "VAL_001", "Source ImageData cannot be nil")
ErrorHandler:error("ImageScaler", "VAL_001", "Source ImageData cannot be nil")
end
if srcW <= 0 or srcH <= 0 or destW <= 0 or destH <= 0 then
ErrorHandler.warn("ImageScaler", "VAL_002", "Dimensions must be positive", {
ErrorHandler:warn("ImageScaler", "VAL_002", "Dimensions must be positive", {
srcW = srcW,
srcH = srcH,
destW = destW,

View File

@@ -157,16 +157,18 @@ end
--- Layout children within this element according to positioning mode
function LayoutEngine:layoutChildren()
-- Start performance timing first (before any early returns)
local timerName = nil
if LayoutEngine._Performance and LayoutEngine._Performance.enabled and self.element then
-- Use memory address to make timer name unique per element instance
timerName = "layout_" .. (self.element.id or tostring(self.element):match("0x%x+") or "unknown")
LayoutEngine._Performance:startTimer(timerName)
end
if self.element == nil then
return
end
-- Start performance timing
if LayoutEngine._Performance and LayoutEngine._Performance.enabled then
local elementId = self.element.id or "unnamed"
LayoutEngine._Performance:startTimer("layout_" .. elementId)
end
-- Track layout recalculations for performance warnings
self:_trackLayoutRecalculation()
@@ -185,8 +187,8 @@ function LayoutEngine:layoutChildren()
end
-- Stop performance timing
if LayoutEngine._Performance and LayoutEngine._Performance.enabled then
LayoutEngine._Performance:stopTimer("layout_" .. (self.element.id or "unnamed"))
if timerName and LayoutEngine._Performance then
LayoutEngine._Performance:stopTimer(timerName)
end
return
end
@@ -196,8 +198,8 @@ function LayoutEngine:layoutChildren()
self._Grid.layoutGridItems(self.element)
-- Stop performance timing
if LayoutEngine._Performance and LayoutEngine._Performance.enabled then
LayoutEngine._Performance:stopTimer("layout_" .. (self.element.id or "unnamed"))
if timerName and LayoutEngine._Performance then
LayoutEngine._Performance:stopTimer(timerName)
end
return
end
@@ -206,8 +208,8 @@ function LayoutEngine:layoutChildren()
if childCount == 0 then
-- Stop performance timing
if LayoutEngine._Performance and LayoutEngine._Performance.enabled then
LayoutEngine._Performance:stopTimer("layout_" .. (self.element.id or "unnamed"))
if timerName and LayoutEngine._Performance then
LayoutEngine._Performance:stopTimer(timerName)
end
return
end
@@ -611,8 +613,8 @@ function LayoutEngine:layoutChildren()
end
-- Stop performance timing
if LayoutEngine._Performance and LayoutEngine._Performance.enabled then
LayoutEngine._Performance:stopTimer("layout_" .. (self.element.id or "unnamed"))
if timerName and LayoutEngine._Performance then
LayoutEngine._Performance:stopTimer(timerName)
end
end

View File

@@ -102,9 +102,9 @@ function Performance:stopTimer(name)
local startTime = self._timers[name]
if not startTime then
if self.logWarnings then
print(string.format("[Performance] Warning: Timer '%s' was not started", name))
end
-- Silently return nil if timer wasn't started
-- This can happen legitimately when Performance is toggled mid-frame
-- or when layout functions have early returns
return nil
end

View File

@@ -333,7 +333,7 @@ local function validateEnum(value, enumTable, propName, moduleName)
table.sort(validOptions)
if ErrorHandler then
ErrorHandler.error(moduleName or "Element", string.format("%s must be one of: %s. Got: '%s'", propName, table.concat(validOptions, ", "), tostring(value)))
ErrorHandler:error(moduleName or "Element", string.format("%s must be one of: %s. Got: '%s'", propName, table.concat(validOptions, ", "), tostring(value)))
else
error(string.format("%s must be one of: %s. Got: '%s'", propName, table.concat(validOptions, ", "), tostring(value)))
end
@@ -352,14 +352,14 @@ local function validateRange(value, min, max, propName, moduleName)
end
if type(value) ~= "number" then
if ErrorHandler then
ErrorHandler.error(moduleName or "Element", string.format("%s must be a number, got %s", propName, type(value)))
ErrorHandler:error(moduleName or "Element", string.format("%s must be a number, got %s", propName, type(value)))
else
error(string.format("%s must be a number, got %s", propName, type(value)))
end
end
if value < min or value > max then
if ErrorHandler then
ErrorHandler.error(
ErrorHandler:error(
moduleName or "Element",
string.format("%s must be between %s and %s, got %s", propName, tostring(min), tostring(max), tostring(value))
)
@@ -383,7 +383,7 @@ local function validateType(value, expectedType, propName, moduleName)
local actualType = type(value)
if actualType ~= expectedType then
if ErrorHandler then
ErrorHandler.error(moduleName or "Element", string.format("%s must be %s, got %s", propName, expectedType, actualType))
ErrorHandler:error(moduleName or "Element", string.format("%s must be %s, got %s", propName, expectedType, actualType))
else
error(string.format("%s must be %s, got %s", propName, expectedType, actualType))
end
@@ -546,7 +546,7 @@ local function sanitizeText(text, options)
if #text > maxLength then
text = text:sub(1, maxLength)
if ErrorHandler then
ErrorHandler.warn("utils", string.format("Text truncated from %d to %d characters", #text, maxLength))
ErrorHandler:warn("utils", string.format("Text truncated from %d to %d characters", #text, maxLength))
end
end