[SemanticTag("Action", "to quantify stored procedure volume and timing from a buffaly debug log")] prototype ToAnalyzeBuffalyDebugLogProcedures : OpsAction { function Execute(string logFilePath) : string { string script = "$ErrorActionPreference='Stop'; $p='" + logFilePath + "'; if(!(Test-Path $p)){throw \"Missing log: $p\"}; $lines=Get-Content $p; $starts=@{}; $stops=@{}; $dur=@{}; foreach($line in $lines){ if($line -match '\\tStarting\\s+([^\\t]+)'){ $n=$matches[1].Trim(); $starts[$n]=1+($starts[$n]??0) }; if($line -match '\\tStopping\\s+([^\\t]+)\\t([0-9.]+) total seconds'){ $n=$matches[1].Trim(); $stops[$n]=1+($stops[$n]??0); $dur[$n]=($dur[$n]??0)+[double]$matches[2] } }; Write-Output 'TOP_COUNTS'; Write-Output '\"Name\",\"Starts\",\"Stops\",\"TotalMs\"'; $starts.Keys | Sort-Object {-$starts[$_]} | Select-Object -First 30 | ForEach-Object { '\"{0}\",\"{1}\",\"{2}\",\"{3}\"' -f $_, $starts[$_], ($stops[$_]??0), [math]::Round(($dur[$_]??0)*1000) }"; string result = ToExecuteFastPowerShellOperationInWorkingDirectoryWithTimeout.Execute(script, "C:\\logs\\Buffaly", 120); return result; } }