newMemoryProfiler constructs a new instance of MemoryProfiler using the given time function to record the profile execution time.
(p *Profiling, options ...MemoryProfilerOption)
| 55 | // newMemoryProfiler constructs a new instance of MemoryProfiler using the given |
| 56 | // time function to record the profile execution time. |
| 57 | func newMemoryProfiler(p *Profiling, options ...MemoryProfilerOption) *MemoryProfiler { |
| 58 | m := &MemoryProfiler{ |
| 59 | p: p, |
| 60 | alloc: make(stackCounterMap), |
| 61 | start: time.Now(), |
| 62 | } |
| 63 | for _, opt := range options { |
| 64 | opt(m) |
| 65 | } |
| 66 | return m |
| 67 | } |
| 68 | |
| 69 | // NewProfile takes a snapshot of the current memory allocation state and builds |
| 70 | // a profile representing the state of the program memory. |