@@ -86,36 +86,6 @@ type Stats struct {
8686 Steps map [string ]* Stat `json:"steps"`
8787}
8888
89- func calculatePercentiles (stat * Stat ) * Stat {
90- sort .Slice (stat .Durations , func (i , j int ) bool { return stat .Durations [i ] < stat .Durations [j ] })
91- q := func (d * Stat , quantile float64 ) int {
92- return int (float64 (len (d .Durations )) * quantile / 100 )
93- }
94- stat .P50 = stat .Durations [q (stat , 50 )].Round (time .Second )
95- stat .P95 = stat .Durations [q (stat , 95 )].Round (time .Second )
96- stat .P99 = stat .Durations [q (stat , 99 )].Round (time .Second )
97- return stat
98- }
99-
100- func refreshDebugDirs () {
101- _ = os .RemoveAll (DebugDirRoot )
102- if _ , err := os .Stat (DebugDirRoot ); os .IsNotExist (err ) {
103- _ = os .MkdirAll (DebugSubDirWF , os .ModePerm )
104- _ = os .MkdirAll (DebugSubDirJobs , os .ModePerm )
105- }
106- }
107-
108- func dumpResults (enabled bool , dir , name string , data interface {}) error {
109- if enabled {
110- d , err := json .MarshalIndent (data , "" , " " )
111- if err != nil {
112- return err
113- }
114- return os .WriteFile (fmt .Sprintf ("%s/%s-%s.json" , dir , name , uuid .NewString ()[0 :5 ]), d , os .ModeAppend | os .ModePerm )
115- }
116- return nil
117- }
118-
11989func AnalyzeJobsSteps (ctx context.Context , client GitHubActionsClient , cfg * AnalysisConfig ) (* Stats , error ) {
12090 framework .L .Info ().Time ("From" , cfg .TimeStart ).Time ("To" , cfg .TimeEnd ).Msg ("Analyzing workflow runs" )
12191 opts := & github.ListWorkflowRunsOptions {
@@ -360,3 +330,33 @@ func skippedOrInProgressJob(s *github.WorkflowJob) bool {
360330 }
361331 return false
362332}
333+
334+ func calculatePercentiles (stat * Stat ) * Stat {
335+ sort .Slice (stat .Durations , func (i , j int ) bool { return stat .Durations [i ] < stat .Durations [j ] })
336+ q := func (d * Stat , quantile float64 ) int {
337+ return int (float64 (len (d .Durations )) * quantile / 100 )
338+ }
339+ stat .P50 = stat .Durations [q (stat , 50 )].Round (time .Second )
340+ stat .P95 = stat .Durations [q (stat , 95 )].Round (time .Second )
341+ stat .P99 = stat .Durations [q (stat , 99 )].Round (time .Second )
342+ return stat
343+ }
344+
345+ func refreshDebugDirs () {
346+ _ = os .RemoveAll (DebugDirRoot )
347+ if _ , err := os .Stat (DebugDirRoot ); os .IsNotExist (err ) {
348+ _ = os .MkdirAll (DebugSubDirWF , os .ModePerm )
349+ _ = os .MkdirAll (DebugSubDirJobs , os .ModePerm )
350+ }
351+ }
352+
353+ func dumpResults (enabled bool , dir , name string , data interface {}) error {
354+ if enabled {
355+ d , err := json .MarshalIndent (data , "" , " " )
356+ if err != nil {
357+ return err
358+ }
359+ return os .WriteFile (fmt .Sprintf ("%s/%s-%s.json" , dir , name , uuid .NewString ()[0 :5 ]), d , os .ModeAppend | os .ModePerm )
360+ }
361+ return nil
362+ }
0 commit comments