Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

golang 怎么获取 GC 的消耗时间?

还有 GC 的次数,这些用runtime能得到么


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

gogs代码里面抄,下面是字段映射,代码里面关键字sysStatus搜了看就知道了。

https://github.com/gogs/gogs/...

{
        'Uptime': "服务运行时间",
        'NumGoroutine':    '当前 Goroutines 数量',
        'MemAllocated': '当前内存使用量',
        'MemTotal': '所有被分配的内存',
        'MemSys': '内存占用量',
        'Lookups': '指针查找次数',
        'MemMallocs': '内存分配次数',
        'MemFrees': '内存释放次数',
        'HeapAlloc': '当前 Heap 内存使用量',
        'HeapSys': 'Heap 内存占用量',
        'HeapIdle': 'Heap 内存空闲量',
        'HeapInuse': '正在使用的 Heap 内存',
        'HeapReleased': '被释放的 Heap 内存',
        'HeapObjects': 'Heap 对象数量',
        'StackInuse': '启动 Stack 使用量',
        'StackSys': '被分配的 Stack 内存',
        'MSpanInuse': 'MSpan 结构内存使用量',
        'MSpanSys': '被分配的 MSpan 结构内存',
        'MCacheInuse': 'MCache 结构内存使用量',
        'MCacheSys': '被分配的 MCache 结构内存',
        'BuckHashSys': '被分配的剖析哈希表内存',
        'GCSys': '被分配的 GC 元数据内存',
        'OtherSys': '其它被分配的系统内存',
        'NextGC': '下次 GC 内存回收量',
        'LastGC': '距离上次 GC 时间',
        'PauseTotalNs': 'GC 暂停时间总量',
        'PauseNs': '上次 GC 暂停时间',
        'NumGC': 'GC 执行次数',
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...