mirror of
https://github.com/golang/go
synced 2024-11-21 22:04:39 -07:00
fmt: call UpdateMemStats in malloc counter
R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/4830059
This commit is contained in:
parent
bb8e36b4a1
commit
583f72434f
@ -477,28 +477,36 @@ func TestCountMallocs(t *testing.T) {
|
|||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
runtime.UpdateMemStats()
|
||||||
mallocs := 0 - runtime.MemStats.Mallocs
|
mallocs := 0 - runtime.MemStats.Mallocs
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
Sprintf("")
|
Sprintf("")
|
||||||
}
|
}
|
||||||
|
runtime.UpdateMemStats()
|
||||||
mallocs += runtime.MemStats.Mallocs
|
mallocs += runtime.MemStats.Mallocs
|
||||||
Printf("mallocs per Sprintf(\"\"): %d\n", mallocs/100)
|
Printf("mallocs per Sprintf(\"\"): %d\n", mallocs/100)
|
||||||
|
runtime.UpdateMemStats()
|
||||||
mallocs = 0 - runtime.MemStats.Mallocs
|
mallocs = 0 - runtime.MemStats.Mallocs
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
Sprintf("xxx")
|
Sprintf("xxx")
|
||||||
}
|
}
|
||||||
|
runtime.UpdateMemStats()
|
||||||
mallocs += runtime.MemStats.Mallocs
|
mallocs += runtime.MemStats.Mallocs
|
||||||
Printf("mallocs per Sprintf(\"xxx\"): %d\n", mallocs/100)
|
Printf("mallocs per Sprintf(\"xxx\"): %d\n", mallocs/100)
|
||||||
|
runtime.UpdateMemStats()
|
||||||
mallocs = 0 - runtime.MemStats.Mallocs
|
mallocs = 0 - runtime.MemStats.Mallocs
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
Sprintf("%x", i)
|
Sprintf("%x", i)
|
||||||
}
|
}
|
||||||
|
runtime.UpdateMemStats()
|
||||||
mallocs += runtime.MemStats.Mallocs
|
mallocs += runtime.MemStats.Mallocs
|
||||||
Printf("mallocs per Sprintf(\"%%x\"): %d\n", mallocs/100)
|
Printf("mallocs per Sprintf(\"%%x\"): %d\n", mallocs/100)
|
||||||
|
runtime.UpdateMemStats()
|
||||||
mallocs = 0 - runtime.MemStats.Mallocs
|
mallocs = 0 - runtime.MemStats.Mallocs
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
Sprintf("%x %x", i, i)
|
Sprintf("%x %x", i, i)
|
||||||
}
|
}
|
||||||
|
runtime.UpdateMemStats()
|
||||||
mallocs += runtime.MemStats.Mallocs
|
mallocs += runtime.MemStats.Mallocs
|
||||||
Printf("mallocs per Sprintf(\"%%x %%x\"): %d\n", mallocs/100)
|
Printf("mallocs per Sprintf(\"%%x %%x\"): %d\n", mallocs/100)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user