@@ -47,29 +47,25 @@ namespace benchmark {
4747// The task sizes and iteration numbers come from the Driver Perfomance Benchmarking Reference Doc.
4848benchmark_runner::benchmark_runner (std::set<benchmark_type> types) : _types{types} {
4949 // Bson microbenchmarks
50- _microbenches.push_back (
51- std::make_unique<bson_encoding>(" TestFlatEncoding" , 75.31 , " extended_bson/flat_bson.json" ));
52- _microbenches.push_back (
53- std::make_unique<bson_encoding>(" TestDeepEncoding" , 19.64 , " extended_bson/deep_bson.json" ));
54- _microbenches.push_back (
55- std::make_unique<bson_encoding>(" TestFullEncoding" , 57.34 , " extended_bson/full_bson.json" ));
50+ _microbenches.push_back (std::make_unique<bson_encoding>(" TestFlatEncoding" , 75.31 , " extended_bson/flat_bson.json" ));
51+ _microbenches.push_back (std::make_unique<bson_encoding>(" TestDeepEncoding" , 19.64 , " extended_bson/deep_bson.json" ));
52+ _microbenches.push_back (std::make_unique<bson_encoding>(" TestFullEncoding" , 57.34 , " extended_bson/full_bson.json" ));
5653 // TODO CXX-1241: Add bson_decoding equivalents.
5754
5855 // Single doc microbenchmarks
5956 _microbenches.push_back (std::make_unique<run_command>());
60- _microbenches.push_back (
61- std::make_unique<find_one_by_id>(" single_and_multi_document/tweet.json" ));
57+ _microbenches.push_back (std::make_unique<find_one_by_id>(" single_and_multi_document/tweet.json" ));
6258 _microbenches.push_back (std::make_unique<insert_one>(
6359 " TestSmallDocInsertOne" , 2.75 , iterations, " single_and_multi_document/small_doc.json" ));
64- _microbenches.push_back (std::make_unique<insert_one>(
65- " TestLargeDocInsertOne" , 27.31 , 10 , " single_and_multi_document/large_doc.json" ));
60+ _microbenches.push_back (
61+ std::make_unique<insert_one>( " TestLargeDocInsertOne" , 27.31 , 10 , " single_and_multi_document/large_doc.json" ));
6662
6763 // Multi doc microbenchmarks
6864 _microbenches.push_back (std::make_unique<find_many>(" single_and_multi_document/tweet.json" ));
6965 _microbenches.push_back (std::make_unique<bulk_insert>(
7066 " TestSmallDocBulkInsert" , 2.75 , iterations, " single_and_multi_document/small_doc.json" ));
71- _microbenches.push_back (std::make_unique<bulk_insert>(
72- " TestLargeDocBulkInsert" , 27.31 , 10 , " single_and_multi_document/large_doc.json" ));
67+ _microbenches.push_back (
68+ std::make_unique<bulk_insert>( " TestLargeDocBulkInsert" , 27.31 , 10 , " single_and_multi_document/large_doc.json" ));
7369 // CXX-2794: Disable GridFS benchmarks due to long runtime
7470 // _microbenches.push_back(
7571 // std::make_unique<gridfs_upload>("single_and_multi_document/gridfs_large.bin"));
@@ -86,13 +82,10 @@ benchmark_runner::benchmark_runner(std::set<benchmark_type> types) : _types{type
8682 // Need to remove some
8783 if (!_types.empty ()) {
8884 for (auto && it = _microbenches.begin (); it != _microbenches.end ();) {
89- const std::set<benchmark_type>& tags = (*it)->get_tags ();
85+ std::set<benchmark_type> const & tags = (*it)->get_tags ();
9086 std::set<benchmark_type> intersect;
91- std::set_intersection (tags.begin (),
92- tags.end (),
93- _types.begin (),
94- _types.end (),
95- std::inserter (intersect, intersect.begin ()));
87+ std::set_intersection (
88+ tags.begin (), tags.end (), _types.begin (), _types.end (), std::inserter (intersect, intersect.begin ()));
9689
9790 if (intersect.empty ()) {
9891 _microbenches.erase (it);
@@ -112,8 +105,7 @@ void benchmark_runner::run_microbenches() {
112105
113106 auto score = bench->get_results ();
114107
115- std::cout << bench->get_name () << " : "
116- << static_cast <double >(score.get_percentile (50 ).count ()) / 1000.0
108+ std::cout << bench->get_name () << " : " << static_cast <double >(score.get_percentile (50 ).count ()) / 1000.0
117109 << " second(s) | " << score.get_score () << " MB/s" << std::endl
118110 << std::endl;
119111 }
@@ -168,12 +160,9 @@ void benchmark_runner::write_scores() {
168160 using builder::basic::sub_document;
169161
170162 auto doc = builder::basic::document{};
171- doc.append (kvp (" info" , [](sub_document subdoc) {
172- subdoc.append (kvp (" test_name" , " C++ Driver microbenchmarks" ));
173- }));
163+ doc.append (kvp (" info" , [](sub_document subdoc) { subdoc.append (kvp (" test_name" , " C++ Driver microbenchmarks" )); }));
174164
175- auto write_time =
176- [](const std::chrono::time_point<std::chrono::system_clock> t) -> std::string {
165+ auto write_time = [](std::chrono::time_point<std::chrono::system_clock> const t) -> std::string {
177166 std::time_t t1 = std::chrono::system_clock::to_time_t (t);
178167 std::ostringstream oss;
179168 oss << std::put_time (std::gmtime (&t1), " %Y-%m-%dT%H:%M:%S" ) << " +00:00" ;
@@ -189,10 +178,10 @@ void benchmark_runner::write_scores() {
189178 std::cout << " Individual microbenchmark scores:" << std::endl << " ===========" << std::endl;
190179 for (auto && bench : _microbenches) {
191180 auto & score = bench->get_results ();
192- const auto bench_time = static_cast <double >(score.get_percentile (50 ).count ()) / 1000.0 ;
181+ auto const bench_time = static_cast <double >(score.get_percentile (50 ).count ()) / 1000.0 ;
193182
194- std::cout << bench->get_name () << " : " << bench_time << " seconds | " << score.get_score ()
195- << " MB/s " << std::endl;
183+ std::cout << bench->get_name () << " : " << bench_time << " seconds | " << score.get_score () << " MB/s "
184+ << std::endl;
196185
197186 auto metric_doc = builder::basic::document{};
198187 metric_doc.append (kvp (" name" , bench->get_name ()));
@@ -232,4 +221,4 @@ void benchmark_runner::write_scores() {
232221 std::ofstream os{" results.json" };
233222 os << ' [' << bsoncxx::to_json (doc.view ()) << ' ]' ;
234223}
235- } // namespace benchmark
224+ } // namespace benchmark
0 commit comments