From fa58994a1424239094d6ab3b726f8c05b34584db Mon Sep 17 00:00:00 2001 From: JCrawfy Date: Sat, 16 Nov 2019 11:25:29 +1300 Subject: [PATCH] add sheet load time benchmark --- benchmarks/spreadsheet-load.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 benchmarks/spreadsheet-load.cpp diff --git a/benchmarks/spreadsheet-load.cpp b/benchmarks/spreadsheet-load.cpp new file mode 100644 index 00000000..dab189ae --- /dev/null +++ b/benchmarks/spreadsheet-load.cpp @@ -0,0 +1,33 @@ +#include +#include +#include + +namespace { +using milliseconds_d = std::chrono::duration; + +void run_test(xlnt::path &const file, int runs = 10) +{ + std::cout << file.string() << "\n\n"; + + xlnt::workbook wb; + std::vector test_timings; + + for (int i = 0; i < runs; ++i) + { + auto start = std::chrono::steady_clock::now(); + wb.load(file); + + auto end = std::chrono::steady_clock::now(); + wb.clear(); + test_timings.push_back(end - start); + + std::cout << milliseconds_d(test_timings.back()).count() << " ms\n"; + } +} +} // namespace + +int main() +{ + run_test(path_helper::benchmark_file("large.xlsx")); + run_test(path_helper::benchmark_file("very_large.xlsx")); +} \ No newline at end of file