Skip to content

Commit f3b3cb5

Browse files
committed
fixes execution time reported in dryRun in case of no dependencies changed
1 parent 13de590 commit f3b3cb5

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

core/DependencyAnalysis.fs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ type ChangeReason =
1010
| NotChanged
1111
| Depends of Target
1212
| DependsMissingTarget of Target
13-
| Refs of string list
1413
| FilesChanged of string list
1514
| Other of string
1615

@@ -25,10 +24,6 @@ let getExecTime ctx target =
2524
(fun ch -> Storage.GetResult(target, ch)) |> ctx.Db.PostAndReply
2625
|> Option.fold (fun _ r -> r.Steps |> List.sumBy (fun s -> s.OwnTime)) 0<ms>
2726

28-
let targetName = function
29-
| PhonyAction a -> a
30-
| FileTarget file -> file.Name
31-
3227
/// Gets single dependency state and reason of a change.
3328
let getDepState getVar getFileList (getChangedDeps: Target -> ChangeReason list) = function
3429
| FileDep (a:File, wrtime) when not((File.exists a) && abs((File.getLastWriteTime a - wrtime).TotalMilliseconds) < TimeCompareToleranceMs) ->
@@ -111,8 +106,13 @@ let getChangeReasons ctx getTargetDeps target =
111106

112107
// gets task duration and list of targets it depends on. No clue why one method does both.
113108
let getDurationDeps ctx getDeps t =
114-
let collectTargets = List.collect (function |Depends t |DependsMissingTarget t -> [t] | _ -> [])
115-
getExecTime ctx t, getDeps t |> collectTargets
109+
let deps = getDeps t |> List.collect (function |Depends t |DependsMissingTarget t -> [t] | _ -> [])
110+
match deps with
111+
| [] -> 0<ms>, []
112+
| _ -> (getExecTime ctx t, deps)
113+
// |> fun (tt,dd) ->
114+
// printfn "For task %A duration:%A deps:%A" t tt dd
115+
// (tt,dd)
116116

117117
/// Dumps all dependencies for particular target
118118
let dumpDeps (ctx: ExecContext) (target: Target list) =

core/ExecCore.fs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,19 @@ module internal ExecCore =
194194

195195
let targetGroups = groups |> List.map (List.map (makeTarget ctx)) in
196196
let toSec v = float (v / 1<ms>) * 0.001
197-
let endTime = Progress.estimateEndTime2 (getDurationDeps ctx getDeps) options.Threads targetGroups |> toSec
197+
let endTime = Progress.estimateEndTime (getDurationDeps ctx getDeps) options.Threads targetGroups |> toSec
198198

199199
targetGroups |> List.collect id |> List.iter (showTargetStatus 0)
200-
201-
let parallelismMsg =
202-
let endTimeTotal = Progress.estimateEndTime2 (getDurationDeps ctx getDeps) 1 targetGroups |> toSec
203-
if options.Threads > 1 && endTimeTotal > endTime * 1.05 then
204-
sprintf "\n\tTotal tasks duration is (estimate) in %As\n\tParallelist degree: %.2f" endTimeTotal (endTimeTotal / endTime)
205-
else ""
206-
ctx.Logger.Log Message "\n\n\tBuild will be completed (estimate) in %As%s\n" endTime parallelismMsg
200+
let alldeps = targetGroups |> List.collect id |> List.collect getDeps
201+
if List.isEmpty alldeps then
202+
ctx.Logger.Log Message "\n\n\tNo changed dependencies. Nothing to do.\n"
203+
else
204+
let parallelismMsg =
205+
let endTimeTotal = Progress.estimateEndTime (getDurationDeps ctx getDeps) 1 targetGroups |> toSec
206+
if options.Threads > 1 && endTimeTotal > endTime * 1.05 then
207+
sprintf "\n\tTotal tasks duration is (estimate) in %As\n\tParallelist degree: %.2f" endTimeTotal (endTimeTotal / endTime)
208+
else ""
209+
ctx.Logger.Log Message "\n\n\tBuild will be completed (estimate) in %As%s\n" endTime parallelismMsg
207210

208211
let rec unwindAggEx (e:System.Exception) = seq {
209212
match e with

core/Progress.fs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,10 @@ let emptyProgress () =
170170
}
171171
loop ())
172172

173-
/// <summary>
174-
/// Gets estimated execution time.
175-
/// </summary>
176-
let estimateEndTime getDurationDeps threadCount group =
177-
let machine_state = {Cpu = BusyUntil 0<ms> |> List.replicate threadCount; Tasks = Map.empty}
178-
snd <| execMany machine_state getDurationDeps group
179-
180173
/// <summary>
181174
/// Gets estimated execution time for several target groups. Each group start when previous group is completed and runs in parallel.
182175
/// </summary>
183-
let estimateEndTime2 getDurationDeps threadCount groups =
176+
let estimateEndTime getDurationDeps threadCount groups =
184177
let machine_state = {Cpu = BusyUntil 0<ms> |> List.replicate threadCount; Tasks = Map.empty}
185178

186179
groups |> List.fold (fun (state, _) group ->

0 commit comments

Comments
 (0)