]> git.lizzy.rs Git - micro.git/blob - cmd/micro/util/profile.go
More actions and window organization
[micro.git] / cmd / micro / util / profile.go
1 package util
2
3 import (
4         "fmt"
5         "log"
6         "runtime"
7         "time"
8
9         humanize "github.com/dustin/go-humanize"
10 )
11
12 func GetMemStats() string {
13         var memstats runtime.MemStats
14         runtime.ReadMemStats(&memstats)
15         return fmt.Sprintf("Alloc: %s, Sys: %s, GC: %d, PauseTotalNs: %dns", humanize.Bytes(memstats.Alloc), humanize.Bytes(memstats.Sys), memstats.NumGC, memstats.PauseTotalNs)
16 }
17
18 var start time.Time
19
20 func tic(s string) {
21         log.Println("START:", s)
22         start = time.Now()
23 }
24
25 func toc() {
26         end := time.Now()
27         log.Println("END: ElapsedTime in seconds:", end.Sub(start))
28 }