Go to the documentation of this file.00001 #define BENCHPRESS_CONFIG_MAIN
00002
00003 #include <fstream>
00004 #include <benchpress.hpp>
00005 #include <json.hpp>
00006
00007 BENCHMARK("parse jeopardy.json", [](benchpress::context* ctx)
00008 {
00009 for (size_t i = 0; i < ctx->num_iterations(); ++i)
00010 {
00011 std::ifstream input_file("benchmarks/files/jeopardy/jeopardy.json");
00012 nlohmann::json j;
00013 j << input_file;
00014 }
00015 })
00016
00017 BENCHMARK("parse canada.json", [](benchpress::context* ctx)
00018 {
00019 for (size_t i = 0; i < ctx->num_iterations(); ++i)
00020 {
00021 std::ifstream input_file("benchmarks/files/nativejson-benchmark/canada.json");
00022 nlohmann::json j;
00023 j << input_file;
00024 }
00025 })
00026
00027 BENCHMARK("parse citm_catalog.json", [](benchpress::context* ctx)
00028 {
00029 for (size_t i = 0; i < ctx->num_iterations(); ++i)
00030 {
00031 std::ifstream input_file("benchmarks/files/nativejson-benchmark/citm_catalog.json");
00032 nlohmann::json j;
00033 j << input_file;
00034 }
00035 })
00036
00037 BENCHMARK("parse twitter.json", [](benchpress::context* ctx)
00038 {
00039 for (size_t i = 0; i < ctx->num_iterations(); ++i)
00040 {
00041 std::ifstream input_file("benchmarks/files/nativejson-benchmark/twitter.json");
00042 nlohmann::json j;
00043 j << input_file;
00044 }
00045 })
00046
00047 BENCHMARK("dump jeopardy.json", [](benchpress::context* ctx)
00048 {
00049 std::ifstream input_file("benchmarks/files/jeopardy/jeopardy.json");
00050 nlohmann::json j;
00051 j << input_file;
00052 std::ofstream output_file("jeopardy.dump.json");
00053
00054 ctx->reset_timer();
00055 for (size_t i = 0; i < ctx->num_iterations(); ++i)
00056 {
00057 output_file << j;
00058 }
00059
00060 std::remove("jeopardy.dump.json");
00061 })
00062
00063 BENCHMARK("dump jeopardy.json with indent", [](benchpress::context* ctx)
00064 {
00065 std::ifstream input_file("benchmarks/files/jeopardy/jeopardy.json");
00066 nlohmann::json j;
00067 j << input_file;
00068 std::ofstream output_file("jeopardy.dump.json");
00069
00070 ctx->reset_timer();
00071 for (size_t i = 0; i < ctx->num_iterations(); ++i)
00072 {
00073 output_file << std::setw(4) << j;
00074 }
00075
00076 std::remove("jeopardy.dump.json");
00077 })