Commit 5f251953 authored by Armin Sobhani's avatar Armin Sobhani
Browse files

add perf_stl_complement benchmark

parent ce7af325
......@@ -11,6 +11,10 @@ cmake_minimum_required(VERSION 2.8)
project(BoostBioseq)
#if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv8.2-a+fp16+simd+crypto -mtune=tsv110")
#endif()
option(BOOST_BIOSEQ_BUILD_OPENCL_SAMPLES "Build the Boost.Bioseq OpenCL samples" OFF)
if(${BOOST_BIOSEQ_BUILD_OPENCL_SAMPLES})
# find OpenCL
......
......@@ -46,6 +46,11 @@ public:
: ContainerT<CharT, AllocatorT<CharT>>(alloc)
{}
explicit sequence_host(
size_t count)
: ContainerT<CharT, AllocatorT<CharT>>(count)
{}
sequence_host(
const CharT* s
, size_t count)
......
......@@ -19,6 +19,7 @@ find_package(Boost 1.61 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
set(BENCHMARKS
stl_random_sequence
stl_reverse_complement
stl_complement
)
foreach(BENCHMARK ${BENCHMARKS})
......
//----------------------------------------------------------------------------//
// Copyright (c) 2018 Armin Sobhani <arminms@gmail.com>
//
// Distributed under the Boost Software License Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//----------------------------------------------------------------------------//
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#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>
#include <boost/bioseq/type_traits.hpp>
#include <boost/bioseq/sequence.hpp>
#include <boost/bioseq/algorithm/complement.hpp>
#include "perf.hpp"
#include "rss.hpp"
namespace bsq = boost::bioseq;
typedef bsq::sequence_host<char, std::allocator, std::vector> seq;
int main(int argc, char *argv[])
{
perf_parse_args(argc, argv);
std::cout << "size: " << PERF_N << std::endl;
char acgt[] = "ACGT";
std::random_device rd;
std::uniform_int_distribution<int> dist(0, 3);
seq rs(PERF_N);
// rs.reserve(PERF_N);
// create vector of random sequence
std::generate_n(
rs.begin()
// std::back_inserter(rs)
, PERF_N
, [&] () { return acgt[dist(rd)]; } );
char cmplmnt[] =
"--------------------------------"
" !-#$%&-()*+,-./0123456789:;<=>?"
"@TVGHEFCHIJMLKNOPQYSAUBWXRZ[-]^_"
"`tvghefcdijmlknopqysaubwxrz{|}~";
perf_timer t;
for (size_t trial = 0; trial < PERF_TRIALS; ++trial)
{
seq rc(PERF_N);
t.start();
bsq::complement(rs, rc.begin());
t.stop();
}
std::cout << "time: "
<< std::fixed << std::setprecision(2)
<< t.min_time() / 1e6 << " ms"
<< std::endl;
std::cout << "rate: "
<< perf_rate<char>(PERF_N, t.min_time()) << " MB/s"
<< std::endl;
std::cout << "mrss: "
<< bytes2size(get_peak_rss())
<< std::endl;
return 0;
}
\ No newline at end of file
......@@ -38,12 +38,13 @@ int main(int argc, char *argv[])
char acgt[] = "ACGT";
std::random_device rd;
std::uniform_int_distribution<int> dist(0, 3);
seq rs;
rs.reserve(PERF_N);
seq rs(PERF_N);
// rs.reserve(PERF_N);
// create vector of random sequence
std::generate_n(
std::back_inserter(rs)
rs.begin()
// std::back_inserter(rs)
, PERF_N
, [&] () { return acgt[dist(rd)]; } );
......@@ -58,8 +59,8 @@ int main(int argc, char *argv[])
perf_timer t;
for (size_t trial = 0; trial < PERF_TRIALS; ++trial)
{
seq rc;
rc.reserve(PERF_N);
seq rc(PERF_N);
// rc.reserve(PERF_N);
t.start();
// boost::push_back(
......@@ -77,7 +78,8 @@ int main(int argc, char *argv[])
// | boost::adaptors::reversed);
bsq::complement(rs | boost::adaptors::reversed, std::back_inserter(rc));
bsq::complement(rs | boost::adaptors::reversed, rc.begin());
// bsq::complement(rs | boost::adaptors::reversed, std::back_inserter(rc));
t.stop();
// std::cout << "out: " << rc.data() << std::endl;
......
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