// Reload Stats // UnqualifyAllFields unqualifies all fields used by this script to avoid qualify issues. Sub UnqualifyAllFields UNQUALIFY [ReloadStats.Stage] , [ReloadStats.StageNo] , [ReloadStats.Start] , [ReloadStats.End] , [ReloadStats.Duration] ; End Sub // SetupLog sets everything up so the other functions can be used // SetupLog is called at the end of this file. You can remove the last line // and call it yourself at will. // E.g.: CALL SetupLog; Sub SetupLog CALL UnqualifyAllFields; // Create Log Tables ReloadStats: LOAD * INLINE [ ReloadStats.Stage, ReloadStats.StageNo, ReloadStats.Start ]; ReloadStats_Temp: LOAD * INLINE [ ReloadStats.Stage, ReloadStats.StageNo, ReloadStats.Start, ReloadStats.End, ReloadStats.Duration ]; TRACE ; End Sub // StartLog records the begining of a section // It needs an argument in the form of a string with the name of the section. // E.g.: CALL StartLog('Calendar'); Sub StartLog(ReloadStats_StageName) CALL UnqualifyAllFields; // Module Log Initiate CONCATENATE(ReloadStats) LOAD '$(ReloadStats_StageName)' AS [ReloadStats.Stage] , RowNo() AS [ReloadStats.StageNo] , Timestamp(Now()) AS [ReloadStats.Start] AUTOGENERATE(1); End Sub // StopLog records the end of a section // It needs an argument in the form of a string with the name of the section. // The section name should match the name provided in the StartLog function. // E.g.: CALL StopLog('Calendar'); Sub StopLog(ReloadStats_StageName) CALL UnqualifyAllFields; // Module Log End CONCATENATE(ReloadStats_Temp) LOAD [ReloadStats.Stage] , [ReloadStats.StageNo] , [ReloadStats.Start] , Timestamp(Now()) AS [ReloadStats.End] , Interval(Timestamp(Now()) - [ReloadStats.Start]) AS [ReloadStats.Duration] RESIDENT ReloadStats WHERE ReloadStats.Stage = '$(ReloadStats_StageName)'; // Log module duration after it finished LET vReloadStatsDuration = Lookup('ReloadStats.Duration', 'ReloadStats.Stage', '$(ReloadStats_StageName)', 'ReloadStats_Temp'); TRACE [$(ReloadStats_StageName)] took $(vReloadStatsDuration); End Sub // CleanupLog should be called at the very end of the load script // This step is important // E.g.: CALL CleanupLog; Sub CleanupLog // Tidy Up Log Table DROP TABLE ReloadStats; RENAME TABLE ReloadStats_Temp TO ReloadStats; // Reset any used variables LET vReloadStatsDuration = null(); End Sub // Delete this line if you want to call SetupLog manually. CALL SetupLog;