MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / GetProgress

Function GetProgress

utils/timing.go:16–31  ·  view source on GitHub ↗

* * GetProgress to track state of a progress bar @param startTime (time.Time) - the time at which an event started @param expectedDuration (time.Duration) - how long the event is expected to last @return (float64) - the proportion of status bar completion */

(startTime time.Time, expectedDuration time.Duration)

Source from the content-addressed store, hash-verified

14 @return (float64) - the proportion of status bar completion
15*/
16func GetProgress(startTime time.Time, expectedDuration time.Duration) float64 {
17 elapsed := time.Since(startTime)
18 if elapsed <= 0 {
19 return 0
20 }
21 if expectedDuration <= 0 {
22 return 1
23 }
24 if elapsed <= expectedDuration {
25 return 0.8 * (float64(elapsed) / float64(expectedDuration))
26 }
27
28 over := elapsed - expectedDuration
29 ratio := float64(over) / float64(expectedDuration)
30 return 1 - 0.2*math.Exp(-ratio)
31}
32
33func EstimateInstanceRestorationDurationGB(sizeGB int) time.Duration {
34 return estimateInstanceStorageTransferDurationGB(sizeGB)

Callers 3

Calls

no outgoing calls

Tested by

no test coverage detected