<blockquote>
<p>does the fast CSV parser outperform boost::spirit?</p>
</blockquote>
<pre><code>BOOST_AUTO_TEST_CASE(FastCSVSpeed)
{
io::CSVReader<> reader(7, "big_file.csv");
size_t line_num = 0;
auto const t1 =
std::chrono::high_resolution_clock::now();
std::vector<std::string> val(7);
//I will create an api support a vector
while(reader.ReadRow(val[0], val[1], val[2],
val[3], val[4], val[5],
val[6])){
}
auto const t2 =
std::chrono::high_resolution_clock::now();
auto const duration = std::chrono::duration_cast<std::chrono::milliseconds>(t2-t1).count();
std::cout<<"line num "<<line_num<<std::endl;
std::cout<<"duration "<<duration<<std::endl;
}
BOOST_AUTO_TEST_CASE(boostSpiritSpeed)
{
using namespace boost::spirit;
using iter_type = boost::iterator_range<char*>;
io::LineReader reader("big_file.csv");
auto const t1 =
std::chrono::high_resolution_clock::now();
int line = 0;
auto parse_str = [&](iter_type const &)
{
std::cout<<line++<<",";
};
qi::rule<char*, iter_type(), ascii::space_type> charRule =
qi::raw[*~qi::char_(",")];
while(auto *line = reader.next_line()){
qi::phrase_parse(line, line + std::strlen(line),
charRule % ",", ascii::space);
}
auto const t2 =
std::chrono::high_resolution_clock::now();
auto const duration = std::chrono::duration_cast<std::chrono::milliseconds>(t2-t1).count();
std::cout<<"duration "<<duration<<std::endl;
}
</code></pre>
<p>fast csv : 192<br>
boost spirit : 224</p>
<p>In this test, fast csv save the string into std::string already, but spirit haven't.<br>
If I push the string into std::string, spirit took 312 ms to finish the task.</p>
<p>This is just a small test, to implement the Load functions, we need more sophisticated codes, but this small test show us fast csv parser is fast enough.</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/mlpack/mlpack/pull/681#issuecomment-234706170">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJ4bFIXJ0hjjPCBxQyDkHiKy70aX7GTkks5qYctAgaJpZM4Iu08I">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFCH34Tb___JOdL4DfLujuHMjh3Hiks5qYctAgaJpZM4Iu08I.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://github.com/mlpack/mlpack/pull/681#issuecomment-234706170"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>