(b *testing.B)
| 106 | } |
| 107 | |
| 108 | func BenchmarkPublishGobStruct(b *testing.B) { |
| 109 | // stop benchmark for set-up |
| 110 | b.StopTimer() |
| 111 | |
| 112 | s := RunServerOnPort(TEST_PORT) |
| 113 | defer s.Shutdown() |
| 114 | |
| 115 | ec := NewGobEncodedConn(b) |
| 116 | defer ec.Close() |
| 117 | ch := make(chan bool) |
| 118 | |
| 119 | me := &person{Name: "derek", Age: 22, Address: "140 New Montgomery St"} |
| 120 | me.Children = make(map[string]*person) |
| 121 | |
| 122 | me.Children["sam"] = &person{Name: "sam", Age: 19, Address: "140 New Montgomery St"} |
| 123 | me.Children["meg"] = &person{Name: "meg", Age: 17, Address: "140 New Montgomery St"} |
| 124 | |
| 125 | ec.Subscribe("gob_struct", func(p *person) { |
| 126 | if !reflect.DeepEqual(p, me) { |
| 127 | b.Fatalf("Did not receive the correct struct response") |
| 128 | } |
| 129 | ch <- true |
| 130 | }) |
| 131 | |
| 132 | // resume benchmark |
| 133 | b.StartTimer() |
| 134 | |
| 135 | for n := 0; n < b.N; n++ { |
| 136 | ec.Publish("gob_struct", me) |
| 137 | if e := Wait(ch); e != nil { |
| 138 | b.Fatal("Did not receive the message") |
| 139 | } |
| 140 | } |
| 141 | } |
nothing calls this directly
no test coverage detected