mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
add sheet load time benchmark
This commit is contained in:
parent
b22153180a
commit
fa58994a14
33
benchmarks/spreadsheet-load.cpp
Normal file
33
benchmarks/spreadsheet-load.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include <xlnt/xlnt.hpp>
|
||||
#include <chrono>
|
||||
#include <helpers/path_helper.hpp>
|
||||
|
||||
namespace {
|
||||
using milliseconds_d = std::chrono::duration<double, std::milli>;
|
||||
|
||||
void run_test(xlnt::path &const file, int runs = 10)
|
||||
{
|
||||
std::cout << file.string() << "\n\n";
|
||||
|
||||
xlnt::workbook wb;
|
||||
std::vector<std::chrono::steady_clock::duration> 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"));
|
||||
}
|
Loading…
Reference in New Issue
Block a user