summaryrefslogtreecommitdiff
path: root/json/profile
diff options
context:
space:
mode:
authorAdam Scarr <adam@vektah.net>2017-08-06 23:32:10 +1000
committerAdam Scarr <adam@vektah.net>2017-08-06 23:32:10 +1000
commit666ea93dba377f267a2c8ecf97378a420db18383 (patch)
tree5efee0b6e4ccf44b854d9bb65e4e6fa5e7f86548 /json/profile
parent9d7779e8ca5404f26abbd8cce0314d9cee967bba (diff)
Eliminate a bunch of allocations
Diffstat (limited to 'json/profile')
-rw-r--r--json/profile/cpuprofile.bat2
-rw-r--r--json/profile/json.go4
-rw-r--r--json/profile/memprofile.bat2
3 files changed, 5 insertions, 3 deletions
diff --git a/json/profile/cpuprofile.bat b/json/profile/cpuprofile.bat
index 2899eb3..c293b5e 100644
--- a/json/profile/cpuprofile.bat
+++ b/json/profile/cpuprofile.bat
@@ -1,3 +1,3 @@
go build
profile.exe -cpuprofile cpu.out
-go tool pprof --inuse_objects profile.exe cpu.out
+go tool pprof profile.exe cpu.out
diff --git a/json/profile/json.go b/json/profile/json.go
index b94848b..a03d047 100644
--- a/json/profile/json.go
+++ b/json/profile/json.go
@@ -31,11 +31,13 @@ func main() {
}
}()
}
+ max := 1000000
if *memprofile != "" {
runtime.MemProfileRate = 1
+ max = 10000
}
- for i := 0; i < 10000; i++ {
+ for i := 0; i < max; i++ {
_, err := json.Unmarshal(`{"true":true, "false":false, "null": null}`)
if err != nil {
panic(err)
diff --git a/json/profile/memprofile.bat b/json/profile/memprofile.bat
index a9c935e..71873ac 100644
--- a/json/profile/memprofile.bat
+++ b/json/profile/memprofile.bat
@@ -1,3 +1,3 @@
go build
profile.exe -memprofile mem.out
-go tool pprof --inuse_objects profile.exe mem.out
+go tool pprof profile.exe mem.out