BitMagic-C++: xsample01.cpp File Reference

BitMagic-C++

Data Structures | Typedefs | Functions | Variables
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 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

## 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 72 of file xsample01.cpp.

## Function Documentation

## ◆ bv2delta()

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

Examples
  xsample01.cpp.

Definition at line 395 of file xsample01.cpp.

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

Referenced by convert_bv2sv().

## ◆ calc_memory_footprint()

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

Examples
  xsample01.cpp.

Definition at line 281 of file xsample01.cpp.

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

Referenced by main().

## ◆ construct_bvector()

static TBVector* construct_bvector | ( |  | ) |
| static

Examples
  xsample01.cpp.

Definition at line 99 of file xsample01.cpp.

References bm::BM_GAP, and max_size.

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

## ◆ convert_bv2bvs()

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

Examples
  xsample01.cpp.

Definition at line 303 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()

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

Examples
  xsample01.cpp.

Definition at line 419 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::bvector< Alloc >::resize(), 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()

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

Examples
  xsample01.cpp.

Definition at line 365 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 114 of file xsample01.cpp.

Referenced by bv_index::~bv_index().

## ◆ generate_bv_index()

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

Examples
  xsample01.cpp.

Definition at line 260 of file xsample01.cpp.

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

Referenced by main().

## ◆ generate_random_vector()

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

Examples
  xsample01.cpp.

Definition at line 217 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 |  | ) |

Examples
  xsample01.cpp.

Definition at line 798 of file xsample01.cpp.

References calc_memory_footprint(), convert_bv2bvs(), convert_bv2sv(), convert_bv2vect(), bm::chrono_taker::ct_ops_per_sec, generate_bv_index(), bm::chrono_taker::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()

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

Examples
  xsample01.cpp.

Definition at line 553 of file xsample01.cpp.

References bm::chrono_taker::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()

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

Examples
  xsample01.cpp.

Definition at line 612 of file xsample01.cpp.

References bm::chrono_taker::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()

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

Examples
  xsample01.cpp.

Definition at line 738 of file xsample01.cpp.

References bm::chrono_taker::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()

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

Examples
  xsample01.cpp.

Definition at line 676 of file xsample01.cpp.

References bm::chrono_taker::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 62 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 59 of file xsample01.cpp.

Referenced by generate_random_vector().

## ◆ index_size

const unsigned index_size = 1000000

Examples
  xsample01.cpp.

Definition at line 53 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 56 of file xsample01.cpp.

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

## ◆ result_set_cnt

const unsigned result_set_cnt = 200

Examples
  xsample01.cpp.

Definition at line 68 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 65 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

Examples
  xsample01.cpp.

Definition at line 76 of file xsample01.cpp.

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