package activator import ( "strings" "time" ) // wakeSteps times one wake step by step for the operator's journal. The // member's wake event carries the total and the spawn (wakeEventMessage); // this says where the rest went, which is what a slow wake's diagnosis // needs and what no single figure can show. type wakeSteps struct { last time.Time steps []wakeStep } type wakeStep struct { name string took time.Duration } // begin starts the clock. A mark before it records nothing. func (s *wakeSteps) begin(now time.Time) { s.last = now } // mark closes the step called name at now and starts the next. func (s *wakeSteps) mark(now time.Time, name string) { if s.last.IsZero() { return } s.steps = append(s.steps, wakeStep{name, now.Sub(s.last)}) s.last = now } func (s *wakeSteps) String() string { parts := make([]string, len(s.steps)) for i, st := range s.steps { parts[i] = st.name + " " + st.took.Round(time.Millisecond).String() } return strings.Join(parts, ", ") }