-
Notifications
You must be signed in to change notification settings - Fork 181
Closed
Description
I have recently tried to switch from toml++ (seeing as toml++ does not preserve whitespace or comments), but toml11 is too slow at parsing large arrays (it seems that computational complexity is O(N2) with array size). For whatever reason, I have cursed myself with these long arrays in my TOML files, so now my application stalls for several seconds when I load such a file.
Here's a simple example with a array with length 5000:
#include <iostream>
#include <sstream>
#include <chrono>
#include <toml.hpp>
int main(int argc, char** argv)
{
std::stringstream ss;
ss << "[Numbers]\narray = [";
for (int i = 0; i < 5000; i++)
{
if (i != 0) ss << ", ";
ss << i;
}
ss << "]\n";
std::cout << ss.str() << std::endl;;
std::cout << "Start parsing..." << std::endl;
auto start = std::chrono::steady_clock::now();
toml::value input = toml::parse_str(ss.str());
auto end = std::chrono::steady_clock::now();
std::cout << "Finished parsing!" << std::endl;
std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
}
Metadata
Metadata
Assignees
Labels
No labels