Created
October 1, 2024 15:46
-
-
Save baronfel/ad37d0f2708ebe547a5308ca93ec342a to your computer and use it in GitHub Desktop.
Check RAR times
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget: MSBuild.StructuredLogger" | |
open Microsoft.Build.Logging.StructuredLogger | |
open Microsoft.Build.Framework | |
open System | |
open System.Collections.Generic | |
let path = "SbomGenerationSucceedsForValidRequiredParams.Pack.binlog" | |
let reader = BinLogReader() | |
let records = reader.ReadRecords(path) | |
type TaskInfo = | |
{ Start: DateTime | |
Finish: DateTime } | |
member x.Duration = | |
if x.Start <> DateTime.MinValue | |
&& x.Finish <> DateTime.MaxValue then | |
x.Finish - x.Start | |
else | |
TimeSpan.Zero | |
let taskDict = Dictionary<BuildEventContext, TaskInfo>() | |
let taskRecords = | |
records | |
|> Seq.choose (fun r -> | |
match r.Args with | |
| :? TaskStartedEventArgs as tae -> Some(tae :> BuildEventArgs) | |
| :? TaskFinishedEventArgs as tae -> Some tae | |
| _ -> None) | |
taskRecords | |
|> Seq.iter (fun t -> | |
match t with | |
| (:? TaskStartedEventArgs as taskStarted) when taskStarted.TaskName = "ResolveAssemblyReference" -> | |
match taskDict.TryGetValue(taskStarted.BuildEventContext) with | |
| true, r -> taskDict[taskStarted.BuildEventContext] <- { r with Start = taskStarted.Timestamp } | |
| false, _ -> | |
taskDict[taskStarted.BuildEventContext] <- { Start = taskStarted.Timestamp | |
Finish = DateTime.MaxValue } | |
| (:? TaskFinishedEventArgs as taskFinished) when taskFinished.TaskName = "ResolveAssemblyReference" -> | |
match taskDict.TryGetValue(taskFinished.BuildEventContext) with | |
| true, r -> taskDict[taskFinished.BuildEventContext] <- { r with Finish = taskFinished.Timestamp } | |
| false, _ -> | |
taskDict[taskFinished.BuildEventContext] <- { Start = DateTime.MinValue | |
Finish = taskFinished.Timestamp } | |
| _ -> ()) | |
taskDict | |
|> Seq.sumBy (fun (KeyValue (k, v)) -> v.Duration.TotalMilliseconds) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment