xsample01.cpp File Reference

Example: Example: memory consumption techniques. More...

`#include <iostream>`
`#include <memory>`
`#include <map>`
`#include <vector>`
`#include <chrono>`
`#include <algorithm>`
`#include <stdexcept>`
`#include "bm.h"`
`#include "bmalgo.h"`
`#include "bmtimer.h"`
`#include "bmserial.h"`
`#include "bmsparsevec.h"`
`#include "bmsparsevec_algo.h"`
`#include "bmsparsevec_serial.h"`
`#include "bmalgo_similarity.h"`
`#include "bmdbg.h"`
`#include "bmundef.h"`
Include dependency graph for xsample01.cpp:

Go to the source code of this file.

## Data Structures

struct | gap_len_table_sparse< T >
struct | bv_index
struct | bvs_index
struct | vect_index
struct | sparse_vect_index
struct | sparse_vect_index::vect_addr

## Typedefs

typedef bm::bvector | TBVector

## Functions

static TBVector * | construct_bvector ()
template<typename TM>
void | destroy_map (TM &id_map)
static void | generate_random_vector (TBVector *bv)
static void | generate_bv_index (bv_index &bvi)
static size_t | calc_memory_footprint (const bv_index &bvi)
static size_t | convert_bv2bvs (const bv_index &bvi, bvs_index &bvs)
static size_t | convert_bv2vect (const bv_index &bvi, vect_index &vidx)
static void | bv2delta (const TBVector &bv, std::vector< unsigned > &vect)
static size_t | convert_bv2sv (const bv_index &bvi, sparse_vect_index &sv_idx)
static void | speed_test_bv_index (const bv_index &bvi)
static void | speed_test_bvs_index (const bvs_index &bvs)
static void | speed_test_vect_index (const vect_index &vecti)
static void | speed_test_sv_index (const sparse_vect_index &svi)
int | main (void)

## Variables

const unsigned | index_size = 1000000
const unsigned | max_size = 2000000
const unsigned | bits_per_vect = 5
const unsigned | benchmark_ops = 1000
const unsigned | sample_cnt = 250
const unsigned | result_set_cnt = 200
bm::chrono_taker ::duration_map_type | timing_map
template<bool T>
const bm::gap_word_t | gap_len_table_sparse< T >::_len [bm::gap_levels]

## Detailed Description

Example: Example: memory consumption techniques.

Definition in file xsample01.cpp.

## Typedef Documentation

## TBVector

typedef bm::bvector TBVector

Examples
  xsample01.cpp.

Definition at line 74 of file xsample01.cpp.

## Function Documentation

## bv2delta()

void bv2delta | ( | const TBVector & | bv,
|  | std::vector< unsigned > & | vect )

static

Examples
  xsample01.cpp.

Definition at line 397 of file xsample01.cpp.

References bm::bvector< Alloc >::first(), and bm::bvector< Alloc >::iterator_base::valid().

Referenced by convert_bv2sv().

## calc_memory_footprint()

size_t calc_memory_footprint | ( | const bv_index & | bvi | ) |

static

Examples
  xsample01.cpp.

Definition at line 283 of file xsample01.cpp.

References bm::bvector< Alloc >::calc_stat(), bv_index::idx_, and bm::bv_statistics::memory_used.

Referenced by main().

## construct_bvector()

TBVector * construct_bvector | ( |  | ) |

static

Examples
  xsample01.cpp.

Definition at line 101 of file xsample01.cpp.

References gap_len_table_sparse< T >::_len, bm::BM_GAP, and max_size.

Referenced by bm::basic_bmatrix< BV >::construct_row(), bm::basic_bmatrix< BV >::construct_row(), bm::basic_bmatrix< BV >::copy_from(), and generate_bv_index().

## convert_bv2bvs()

size_t convert_bv2bvs | ( | const bv_index & | bvi,
|  | bvs_index & | bvs )

static

Examples
  xsample01.cpp.

Definition at line 305 of file xsample01.cpp.

References bm::serializer< BV >::byte_order_serialization(), bm::bvector< Alloc >::calc_stat(), bm::bvector< Alloc >::compare(), bm::deserialize(), bm::serializer< BV >::gap_length_serialization(), bv_index::idx_, bvs_index::idx_, bm::bv_statistics::max_serialize_mem, bm::serializer< BV >::serialize(), and bm::serializer< BV >::set_compression_level().

Referenced by main().

## convert_bv2sv()

size_t convert_bv2sv | ( | const bv_index & | bvi,
|  | sparse_vect_index & | sv_idx )

static

Examples
  xsample01.cpp.

Definition at line 421 of file xsample01.cpp.

References BM_DECLARE_TEMP_BLOCK, bv2delta(), bm::bvector< Alloc >::first(), sparse_vect_index::get_vector(), bv_index::idx_, sparse_vect_index::idx_, bm::sparse_vector< Val, BV >::import(), sparse_vect_index::vect_addr::offset, bm::bvector< Alloc >::opt_compress, bm::sparse_vector< Val, BV >::optimize(), bm::sparse_vector< Val, BV >::set(), sparse_vect_index::vect_addr::size, sparse_vect_index::sv_storage1_, sparse_vect_index::sv_storage_, and bm::bvector< Alloc >::iterator_base::valid().

Referenced by main().

## convert_bv2vect()

size_t convert_bv2vect | ( | const bv_index & | bvi,
|  | vect_index & | vidx )

static

Examples
  xsample01.cpp.

Definition at line 367 of file xsample01.cpp.

References bm::bvector< Alloc >::count(), bm::bvector< Alloc >::first(), bv_index::idx_, vect_index::idx_, and bm::bvector< Alloc >::iterator_base::valid().

Referenced by main().

## destroy_map()

template<typename TM>

void destroy_map | ( | TM & | id_map | ) |

Examples
  xsample01.cpp.

Definition at line 116 of file xsample01.cpp.

References bm::bvector< Alloc >::clear().

Referenced by bv_index::~bv_index().

## generate_bv_index()

void generate_bv_index | ( | bv_index & | bvi | ) |

static

Examples
  xsample01.cpp.

Definition at line 262 of file xsample01.cpp.

References construct_bvector(), generate_random_vector(), bv_index::idx_, and index_size.

Referenced by main().

## generate_random_vector()

void generate_random_vector | ( | TBVector * | bv | ) |

static

Examples
  xsample01.cpp.

Definition at line 219 of file xsample01.cpp.

References bits_per_vect, max_size, and bm::bvector< Alloc >::set_bit().

Referenced by generate_bv_index().

## main()

int main | ( | void |  | ) |

Definition at line 800 of file xsample01.cpp.

References calc_memory_footprint(), convert_bv2bvs(), convert_bv2sv(), convert_bv2vect(), bm::chrono_taker< TOut >::ct_ops_per_sec, generate_bv_index(), bm::chrono_taker< TOut >::print_duration_map(), speed_test_bv_index(), speed_test_bvs_index(), speed_test_sv_index(), speed_test_vect_index(), and timing_map.

## speed_test_bv_index()

void speed_test_bv_index | ( | const bv_index & | bvi | ) |

static

Examples
  xsample01.cpp.

Definition at line 555 of file xsample01.cpp.

References bm::chrono_taker< TOut >::add_repeats(), benchmark_ops, bm::BM_GAP, bm::bvector< Alloc >::clear(), bm::bvector< Alloc >::first(), bv_index::idx_, index_size, bm::bvector< Alloc >::optimize(), result_set_cnt, sample_cnt, timing_map, and bm::bvector< Alloc >::iterator_base::valid().

Referenced by main().

## speed_test_bvs_index()

void speed_test_bvs_index | ( | const bvs_index & | bvs | ) |

static

Examples
  xsample01.cpp.

Definition at line 614 of file xsample01.cpp.

References bm::chrono_taker< TOut >::add_repeats(), benchmark_ops, BM_DECLARE_TEMP_BLOCK, bm::BM_GAP, bm::bvector< Alloc >::clear(), bm::operation_deserializer< BV >::deserialize(), bm::bvector< Alloc >::first(), bvs_index::idx_, index_size, bm::bvector< Alloc >::optimize(), result_set_cnt, sample_cnt, bm::set_OR, timing_map, and bm::bvector< Alloc >::iterator_base::valid().

Referenced by main().

## speed_test_sv_index()

void speed_test_sv_index | ( | const sparse_vect_index & | svi | ) |

static

Examples
  xsample01.cpp.

Definition at line 740 of file xsample01.cpp.

References bm::chrono_taker< TOut >::add_repeats(), benchmark_ops, bm::BM_GAP, bm::bvector< Alloc >::clear(), bm::combine_or(), bm::bvector< Alloc >::end(), bm::bvector< Alloc >::first(), sparse_vect_index::get_vector(), sparse_vect_index::idx_, index_size, bm::bvector< Alloc >::optimize(), result_set_cnt, sample_cnt, timing_map, and bm::bvector< Alloc >::iterator_base::valid().

Referenced by main().

## speed_test_vect_index()

void speed_test_vect_index | ( | const vect_index & | vecti | ) |

static

Examples
  xsample01.cpp.

Definition at line 678 of file xsample01.cpp.

References bm::chrono_taker< TOut >::add_repeats(), benchmark_ops, bm::BM_GAP, bm::bvector< Alloc >::clear(), bm::combine_or(), bm::bvector< Alloc >::end(), bm::bvector< Alloc >::first(), vect_index::idx_, index_size, bm::bvector< Alloc >::optimize(), result_set_cnt, sample_cnt, timing_map, and bm::bvector< Alloc >::iterator_base::valid().

Referenced by main().

## Variable Documentation

## benchmark_ops

const unsigned benchmark_ops = 1000

Examples
  xsample01.cpp.

Definition at line 64 of file xsample01.cpp.

Referenced by speed_test_bv_index(), speed_test_bvs_index(), speed_test_sv_index(), and speed_test_vect_index().

## bits_per_vect

const unsigned bits_per_vect = 5

Examples
  xsample01.cpp.

Definition at line 61 of file xsample01.cpp.

Referenced by generate_random_vector().

## gap_len_table_sparse< T >::_len

template<bool T>

const bm::gap_word_t gap_len_table_sparse< T >::_len[bm::gap_levels]

Initial value:
=
{ 8, 32, 128, 512 }

Examples
  xsample01.cpp.

Definition at line 94 of file xsample01.cpp.

## index_size

const unsigned index_size = 1000000

Examples
  xsample01.cpp.

Definition at line 55 of file xsample01.cpp.

Referenced by generate_bv_index(), speed_test_bv_index(), speed_test_bvs_index(), speed_test_sv_index(), and speed_test_vect_index().

## max_size

const unsigned max_size = 2000000

Examples
  xsample01.cpp.

Definition at line 58 of file xsample01.cpp.

Referenced by construct_bvector(), bm::aggregator< BV >::find_effective_sub_block_size(), and generate_random_vector().

## result_set_cnt

const unsigned result_set_cnt = 200

Examples
  xsample01.cpp.

Definition at line 70 of file xsample01.cpp.

Referenced by speed_test_bv_index(), speed_test_bvs_index(), speed_test_sv_index(), and speed_test_vect_index().

## sample_cnt

const unsigned sample_cnt = 250

Examples
  xsample01.cpp.

Definition at line 67 of file xsample01.cpp.

Referenced by speed_test_bv_index(), speed_test_bvs_index(), speed_test_sv_index(), and speed_test_vect_index().

## timing_map

bm::chrono_taker ::duration_map_type timing_map

Definition at line 78 of file xsample01.cpp.