(b *testing.B)
| 115 | } |
| 116 | |
| 117 | func BenchmarkJSONStringify(b *testing.B) { |
| 118 | b.StopTimer() |
| 119 | vm := New() |
| 120 | var createObj func(level int) *Object |
| 121 | createObj = func(level int) *Object { |
| 122 | o := vm.NewObject() |
| 123 | o.Set("field1", "test") |
| 124 | o.Set("field2", 42) |
| 125 | if level > 0 { |
| 126 | level-- |
| 127 | o.Set("obj1", createObj(level)) |
| 128 | o.Set("obj2", createObj(level)) |
| 129 | } |
| 130 | return o |
| 131 | } |
| 132 | |
| 133 | o := createObj(3) |
| 134 | json := vm.Get("JSON").(*Object) |
| 135 | stringify, _ := AssertFunction(json.Get("stringify")) |
| 136 | b.StartTimer() |
| 137 | for i := 0; i < b.N; i++ { |
| 138 | stringify(nil, o) |
| 139 | } |
| 140 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…