Commit 3b4c5fe6 authored by Armin Sobhani's avatar Armin Sobhani
Browse files

change perf_stl_reverse_complement to use push_back and indexed base complementing

parent 20641ec5
......@@ -15,6 +15,7 @@
#include <random>
#include <boost/range/algorithm/copy.hpp>
#include <boost/range/algorithm_ext/push_back.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <boost/range/adaptor/reversed.hpp>
......@@ -45,6 +46,14 @@ int main(int argc, char *argv[])
, PERF_N
, [&] () { return acgt[dist(rd)]; } );
char cmplmnt[] =
"--------------------------------"
" !-#$%&-()*+,-./0123456789:;<=>?"
"@TVGHEFCHIJMLKNOPQYSAUBWXRZ[-]^_"
"`tvghefcdijmlknopqysaubwxrz{|}~";
// std::cout << "in: " << rs.data() << std::endl;
perf_timer t;
for (size_t trial = 0; trial < PERF_TRIALS; ++trial)
{
......@@ -52,17 +61,25 @@ int main(int argc, char *argv[])
rc.reserve(PERF_N);
t.start();
boost::copy(
rs | boost::adaptors::transformed(
[] (char b) { if ('A' == b) return 'T';
else if ('T' == b) return 'A';
else if ('C' == b) return 'G';
else if ('G' == b) return 'C';
else return b ; } )
| boost::adaptors::reversed
, std::back_inserter(rc));
boost::push_back(
rc
// , rs | boost::adaptors::transformed(
// [] (char b) { if ('A' == b) return 'T';
// else if ('T' == b) return 'A';
// else if ('C' == b) return 'G';
// else if ('G' == b) return 'C';
// else return b ; } )
, rs | boost::adaptors::transformed(
[ &cmplmnt ] (char b) { return cmplmnt[b]; } )
| boost::adaptors::reversed);
t.stop();
// std::cout << "out: " << rc.data() << std::endl;
}
std::cout << "time: "
<< std::fixed << std::setprecision(2)
<< t.min_time() / 1e6 << " ms"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment