| 176 | } |
| 177 | |
| 178 | void TestJsonWriter::DoBenchmark(const Message& pb) { |
| 179 | int64_t total_len = 0; |
| 180 | Stopwatch sw; |
| 181 | sw.start(); |
| 182 | while (sw.elapsed().wall_seconds() < 5) { |
| 183 | std::ostringstream str; |
| 184 | JsonWriter jw(&str, JsonWriter::COMPACT); |
| 185 | jw.StartArray(); |
| 186 | for (int i = 0; i < 10000; i++) { |
| 187 | jw.Protobuf(pb); |
| 188 | } |
| 189 | jw.EndArray(); |
| 190 | total_len += str.str().size(); |
| 191 | } |
| 192 | sw.stop(); |
| 193 | double mbps = total_len / 1024.0 / 1024.0 / sw.elapsed().user_cpu_seconds(); |
| 194 | LOG(INFO) << "Throughput: " << mbps << "MB/sec"; |
| 195 | } |
| 196 | |
| 197 | TEST_F(TestJsonWriter, BenchmarkAllTypes) { |
| 198 | DoBenchmark(MakeAllTypesPB()); |
nothing calls this directly
no test coverage detected