Skip to content

ruslanSorokin/algorithms-hw-1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Как и на чём запускать

Windows:
MinGW-GCC version 12.1.0 (Без сборки параметризованных тестов из googletest)
MinGW-Clang version 14.0.4
Linux/MacOS:
GNU-GCC version 11.2.0
LLVM-Clang version 14.0.0 Apple-Clang version 13.0.0

  • Основной функционал прописан на C++11 без использования сторонних библиотек
  • Для тестирования использованы googletest и gtest-parallel
  • Для замеров использован benchmark
  • Чтобы запустить проект и воспользоваться основным функционалом достаточно клонировать его к себе и собрать через cmake цель Matrix_App
  • Точка входа в приложение находится в файле src/main.cpp
  • Для запуска тестов и бенчмарка необходимо инициализировать и обновить модули командами
$ git submodule init
$ git submodule update

CMake targets:

  • Matrix_App - entry-point
  • Matrix_Test - googletest
  • Matrix_Benchmark - google-benchmark

Google Benchmark:

  • Собрать цель Matrix_Benchmark
  • Запустить исполняемый файл со следующими параметрами:
--benchmark_repetitions=3
--benchmark_out="{Path-from-binary-to-root-folder}/log/benchmark/Overall.json"
--benchmark_out_format=json
--benchmark_filter=Search*
  • Запустить parse_benchmark.py
  • Запустить charts.py
  • Графики находятся в директории log/charts

GTest-parallel:

  • Собрать цель Matrix_Test
  • Запустить gtest-parallel в формате:
$ gtest-parallel {path_to_binary}

Исполняемый файл gtest-parallel находится в директории external/gtest-parallel

Реализация

Генерация матриц

Генерация A

void matrix::generator::A(matrix& MatrixInstance) {
const auto Rows = MatrixInstance.Rows_;
const auto Columns = MatrixInstance.Columns_;
for (int i = 0; i < Rows; ++i) {
for (int j = 0; j < Columns; ++j) {
MatrixInstance.Matrix_[i][j] = (static_cast<size_t>(Columns / Rows) * i + j) * 2;
}
}
}

Генерация B

void matrix::generator::B(matrix& MatrixInstance) {
const auto Rows = MatrixInstance.Rows_;
const auto Columns = MatrixInstance.Columns_;
for (int i = 0; i < Rows; ++i) {
for (int j = 0; j < Columns; ++j) {
MatrixInstance.Matrix_[i][j] = (static_cast<size_t>(Columns / Rows) * i * j) * 2;
}
}
}

Генерация C

Не уверен нужно ли было это делать, но, по-моему, на какой-то из практик Вы говорили, что нужно сделать рандомизированное заполнение.

void matrix::generator::C(matrix& MatrixInstance) {
const auto Rows = MatrixInstance.Rows_;
const auto Columns = MatrixInstance.Columns_;
constexpr size_t DistributionDensity = 8;
const size_t LowerBound = std::numeric_limits<size_t>::min() + 1;
const size_t Epsilon = (Columns + Rows) / DistributionDensity;
auto get_random_int = [](const size_t LowerBound, const size_t Length) -> size_t {
static std::random_device rd;
/*
* Hardware or software random generator for seeding Mersenne Twister.
* Its constructor is quit expensive, so we will create it as a static variable
*/
static std::mt19937 mt {rd()};
/*
* Mersenne Twister engine is also too expensive to call its constructor every time,
* and it weights about 5KB, it is too big for storing it on the stack,
* so we are creating it as a static variable as well
*/
static std::uniform_int_distribution<size_t> dist(LowerBound, LowerBound + Length);
return dist(mt);
};
for (uint32_t Row = 0; Row < Rows; ++Row) {
for (uint32_t Column = 0; Column < Columns; ++Column) {
size_t CurrentCellLowerBound = LowerBound;
if (Row >= 1) {
CurrentCellLowerBound = std::max(CurrentCellLowerBound,
MatrixInstance[Row - 1][Column]);
}
if (Column >= 1) {
CurrentCellLowerBound = std::max(CurrentCellLowerBound,
MatrixInstance[Row][Column - 1]);
}
CurrentCellLowerBound += 1;
MatrixInstance[Row][Column] = CurrentCellLowerBound + get_random_int(CurrentCellLowerBound, Epsilon);
}
}
}

Алгоритмы поиска

Линейный

O(M * N)

auto matrix::search::linear(const matrix& Matrix,
const size_t Target) -> bool {
const auto Rows = Matrix.Rows_;
const auto Columns = Matrix.Columns_;
for (uint32_t Row = 0; Row < Rows; ++Row) {
for (uint32_t Column = 0; Column < Columns; ++Column) {
if (Matrix[Row][Column] == Target) {
return true;
}
}
}
return false;
}

Бинарный(варьируемый в зависимости от отношения MxN)

O(min(M, N) * log(max(M, N)))

auto matrix::search::binary(const matrix& Matrix,
const size_t Target) -> bool {
constexpr int MagicCoefficient = 4;
/*
* I don't know why, but there is an interesting thing:
* When you run both vertical and horizontal binary searches on the same matrix
* with the same rows and columns, vertical search is slightly faster.
* I think it is related to some compiler-optimization stuff, but it is still a bit strange.
*
* I would have understood, if it would be in the opposite way,
* because vertical search dereferences values from different vectors,
* whereas horizontal search dereferences values from the same vector,
* but it is not.
*
* Generally speaking, vertical search by some reasons is slightly faster in the same conditions,
* so we are taking it into account, when choosing which one to run by multiplying Rows by this coefficient
*
*
* Update
* It seems, that it is cache-line optimization stuff:
* Both vertical and horizontal searches have a great number of cache misses,
* because all random access algorithms are not about cache-line optimization.
*
* In the same time, linear horizontal traversing stores every horizontal fragment in the cache,
* whereas linear vertical traversing misses every new cell.
* Exactly because that reason, we transpose matrix, before multiplying.
*
* I find by a several runs, that 4 fits perfectly for this MagicCoefficient,
* so I remove TO-DO label
*/
const auto Rows = static_cast<int>(Matrix.Rows_);
const auto Columns = static_cast<int>(Matrix.Columns_);
if (Rows * MagicCoefficient >= Columns) {
for (int ColumnIndex = 0; ColumnIndex < Columns; ++ColumnIndex) {
if (Matrix[0][ColumnIndex] <= Target && Target <= Matrix[Rows - 1][ColumnIndex]) {
if (Target == Matrix[vertical_lower_bound(Matrix, ColumnIndex, Target, 0, Rows)][ColumnIndex]) {
return true;
}
}
}
} else {
for (int RowIndex = 0; RowIndex < Rows; ++RowIndex) {
if (Matrix[RowIndex][0] <= Target && Target <= Matrix[RowIndex][Columns - 1]) {
if (Target == Matrix[RowIndex][horizontal_lower_bound(Matrix, RowIndex, Target, 0, Columns)]) {
return true;
}
}
}
}
return false;
}

Вспомогательные функции

  • Горизонтальная нижняя граница:

auto horizontal_lower_bound(const matrix& Matrix,
const uint32_t RowIndex,
const size_t Target,
int Left,
int Right) -> int {
for (; Right - Left > 1;) {
int Middle = (Right + Left) / 2;
if (Matrix[RowIndex][Middle] > Target) {
Right = Middle;
} else {
Left = Middle;
}
}
return Right - 1;
}

  • Вертикальная нижняя граница:

auto vertical_lower_bound(const matrix& Matrix,
const uint32_t ColumnIndex,
const size_t Target,
int Top,
int Bottom) -> int {
for (; Bottom - Top > 1;) {
int Middle = (Bottom + Top) / 2;
if (Matrix[Middle][ColumnIndex] > Target) {
Bottom = Middle;
} else {
Top = Middle;
}
}
return Bottom - 1;
}

Лестничный

O(M + N)

auto matrix::search::staircase(const matrix& Matrix,
const size_t Target) -> bool {
const auto Rows = static_cast<int>(Matrix.Rows_);
const auto Columns = static_cast<int>(Matrix.Columns_);
int RowIndex = 0;
int ColumnIndex = Columns - 1;
for (; RowIndex < Rows && ColumnIndex >= 0;) {
if (Matrix[RowIndex][ColumnIndex] == Target) {
return true;
}
if (Matrix[RowIndex][ColumnIndex] > Target) {
--ColumnIndex;
} else {
++RowIndex;
}
}
return false;
}

Лестничный-бинарный

O(M * log(N))

auto matrix::search::staircase_with_binary(const matrix& Matrix,
size_t Target) -> bool {
const auto Rows = static_cast<int>(Matrix.Rows_);
const auto Columns = static_cast<int>(Matrix.Columns_);
int RowIndex = 0;
int ColumnIndex = Columns - 1;
for (; RowIndex < Rows && ColumnIndex >= 0;) {
if (Matrix[RowIndex][ColumnIndex] == Target) {
return true;
}
if (Matrix[RowIndex][ColumnIndex] > Target) {
ColumnIndex = horizontal_lower_bound(Matrix, RowIndex, Target, 0, ColumnIndex + 1);
} else {
RowIndex = vertical_upper_bound(Matrix, ColumnIndex, Target, RowIndex, Rows);
}
}
return false;
}

Вспомогательные функции

  • Горизонтальная нижняя граница:

auto horizontal_lower_bound(const matrix& Matrix,
const uint32_t RowIndex,
const size_t Target,
int Left,
int Right) -> int {
for (; Right - Left > 1;) {
int Middle = (Right + Left) / 2;
if (Matrix[RowIndex][Middle] > Target) {
Right = Middle;
} else {
Left = Middle;
}
}
return Right - 1;
}

  • Вертикальная верхняя граница:

auto vertical_upper_bound(const matrix& Matrix,
const uint32_t ColumnIndex,
const size_t Target,
int Top,
int Bottom) -> int {
for (; Bottom - Top > 1;) {
int Middle = (Bottom + Top) / 2;
if (Matrix[Middle][ColumnIndex] < Target) {
Top = Middle;
} else {
Bottom = Middle;
}
}
return Bottom;
}

Лестничный-экспоненциальный

O(M * log(N))

auto matrix::search::staircase_with_exponential(const matrix& Matrix,
size_t Target) -> bool {
const auto Rows = static_cast<int>(Matrix.Rows_);
const auto Columns = static_cast<int>(Matrix.Columns_);
int RowIndex = 0;
int ColumnIndex = Columns - 1;
for (; RowIndex < Rows && ColumnIndex >= 0;) {
if (Matrix[RowIndex][ColumnIndex] == Target) {
return true;
}
if (Matrix[RowIndex][ColumnIndex] > Target) {
ColumnIndex = horizontal_exponential_search(Matrix, RowIndex, Target, 0, ColumnIndex);
} else {
RowIndex = vertical_exponential_search(Matrix, ColumnIndex, Target, RowIndex, Rows - 1);
}
}
return false;
}

Вспомогательные функции

  • Горизонтальный экспоненциальный:

auto horizontal_exponential_search(const matrix& Matrix,
const uint32_t RowIndex,
const size_t Target,
int LeftIndex,
int RightIndex) -> int {
if (Matrix[RowIndex][RightIndex] == Target) {
return RightIndex;
}
int RightBound = RightIndex;
int LeftBound = RightIndex - 1;
int Shift = 1;
for (; LeftBound > LeftIndex && Matrix[RowIndex][LeftBound] > Target;) {
RightBound = LeftBound;
LeftBound -= Shift;
Shift *= 2;
}
return horizontal_lower_bound(Matrix, RowIndex, Target, std::max(LeftIndex, LeftBound), RightBound + 1);
}

  • Вертикальный экспоненциальный:

auto vertical_exponential_search(const matrix& Matrix,
const uint32_t ColumnIndex,
const size_t Target,
int TopIndex,
int BottomIndex) -> int {
if (Matrix[TopIndex][ColumnIndex] == Target) {
return TopIndex;
}
int UpperBound = TopIndex;
int LowerBound = TopIndex + 1;
for (; LowerBound < BottomIndex && Matrix[LowerBound][ColumnIndex] < Target;) {
UpperBound = LowerBound;
LowerBound *= 2;
}
return vertical_upper_bound(Matrix, ColumnIndex, Target, UpperBound, std::min(LowerBound, BottomIndex) + 1);
}

Результаты

Benchmark overall report

Search:
0 : Linear
1 : Binary
2 : Staircase
3 : Staircase_with_binary
4 : Staircase_with_exponential
Generator:
0 : A
1 : B
Target:
0 : 2N + 1
1 : 16N + 1

Benchmark Time CPU Iterations
----------------------------------------------------------------------------------------------------------------------
SearchBenchmark/Search/Rows:2/Columns:8192/Search:0/Target:0/Generator:0 20660 ns 20403 ns 34462
SearchBenchmark/Search/Rows:4/Columns:8192/Search:0/Target:0/Generator:0 41286 ns 41713 ns 17231
SearchBenchmark/Search/Rows:8/Columns:8192/Search:0/Target:0/Generator:0 82479 ns 83705 ns 8960
SearchBenchmark/Search/Rows:16/Columns:8192/Search:0/Target:0/Generator:0 165350 ns 164958 ns 4073
SearchBenchmark/Search/Rows:32/Columns:8192/Search:0/Target:0/Generator:0 329757 ns 329641 ns 2133
SearchBenchmark/Search/Rows:64/Columns:8192/Search:0/Target:0/Generator:0 661547 ns 655692 ns 1120
SearchBenchmark/Search/Rows:128/Columns:8192/Search:0/Target:0/Generator:0 1338709 ns 1339286 ns 560
SearchBenchmark/Search/Rows:256/Columns:8192/Search:0/Target:0/Generator:0 2704320 ns 2722538 ns 264
SearchBenchmark/Search/Rows:512/Columns:8192/Search:0/Target:0/Generator:0 5396916 ns 5440848 ns 112
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:0/Target:0/Generator:0 10628534 ns 10742188 ns 64
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:0/Target:0/Generator:0 21296647 ns 21139706 ns 34
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:0/Target:0/Generator:0 42482265 ns 42279412 ns 17
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:0/Target:0/Generator:0 85192271 ns 84821429 ns 7
SearchBenchmark/Search/Rows:2/Columns:8192/Search:1/Target:0/Generator:0 29.9 ns 29.8 ns 23578947
SearchBenchmark/Search/Rows:4/Columns:8192/Search:1/Target:0/Generator:0 110 ns 107 ns 6400000
SearchBenchmark/Search/Rows:8/Columns:8192/Search:1/Target:0/Generator:0 295 ns 292 ns 2357895
SearchBenchmark/Search/Rows:16/Columns:8192/Search:1/Target:0/Generator:0 820 ns 816 ns 746667
SearchBenchmark/Search/Rows:32/Columns:8192/Search:1/Target:0/Generator:0 1831 ns 1842 ns 373333
SearchBenchmark/Search/Rows:64/Columns:8192/Search:1/Target:0/Generator:0 3843 ns 3836 ns 179200
SearchBenchmark/Search/Rows:128/Columns:8192/Search:1/Target:0/Generator:0 8389 ns 8370 ns 74667
SearchBenchmark/Search/Rows:256/Columns:8192/Search:1/Target:0/Generator:0 17829 ns 17997 ns 37333
SearchBenchmark/Search/Rows:512/Columns:8192/Search:1/Target:0/Generator:0 50597 ns 50000 ns 10000
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:1/Target:0/Generator:0 128256 ns 128348 ns 5600
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:1/Target:0/Generator:0 226302 ns 229492 ns 3200
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:1/Target:0/Generator:0 559902 ns 558036 ns 1120
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:1/Target:0/Generator:0 534841 ns 544085 ns 1120
SearchBenchmark/Search/Rows:2/Columns:8192/Search:2/Target:0/Generator:0 18392 ns 18415 ns 37333
SearchBenchmark/Search/Rows:4/Columns:8192/Search:2/Target:0/Generator:0 27602 ns 27623 ns 24889
SearchBenchmark/Search/Rows:8/Columns:8192/Search:2/Target:0/Generator:0 32224 ns 32227 ns 21333
SearchBenchmark/Search/Rows:16/Columns:8192/Search:2/Target:0/Generator:0 34681 ns 34528 ns 20364
SearchBenchmark/Search/Rows:32/Columns:8192/Search:2/Target:0/Generator:0 35971 ns 36098 ns 19478
SearchBenchmark/Search/Rows:64/Columns:8192/Search:2/Target:0/Generator:0 36962 ns 36830 ns 18667
SearchBenchmark/Search/Rows:128/Columns:8192/Search:2/Target:0/Generator:0 37877 ns 38504 ns 18667
SearchBenchmark/Search/Rows:256/Columns:8192/Search:2/Target:0/Generator:0 39179 ns 39237 ns 17920
SearchBenchmark/Search/Rows:512/Columns:8192/Search:2/Target:0/Generator:0 40955 ns 40806 ns 17231
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:2/Target:0/Generator:0 46413 ns 47085 ns 14933
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:2/Target:0/Generator:0 76496 ns 76730 ns 8960
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:2/Target:0/Generator:0 131832 ns 131138 ns 5600
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:2/Target:0/Generator:0 231730 ns 230164 ns 2987
SearchBenchmark/Search/Rows:2/Columns:8192/Search:3/Target:0/Generator:0 35.6 ns 36.1 ns 20363636
SearchBenchmark/Search/Rows:4/Columns:8192/Search:3/Target:0/Generator:0 101 ns 100 ns 7466667
SearchBenchmark/Search/Rows:8/Columns:8192/Search:3/Target:0/Generator:0 329 ns 330 ns 2133333
SearchBenchmark/Search/Rows:16/Columns:8192/Search:3/Target:0/Generator:0 870 ns 858 ns 746667
SearchBenchmark/Search/Rows:32/Columns:8192/Search:3/Target:0/Generator:0 2061 ns 2086 ns 344615
SearchBenchmark/Search/Rows:64/Columns:8192/Search:3/Target:0/Generator:0 4194 ns 4238 ns 165926
SearchBenchmark/Search/Rows:128/Columns:8192/Search:3/Target:0/Generator:0 8187 ns 8161 ns 74667
SearchBenchmark/Search/Rows:256/Columns:8192/Search:3/Target:0/Generator:0 14471 ns 14439 ns 49778
SearchBenchmark/Search/Rows:512/Columns:8192/Search:3/Target:0/Generator:0 33267 ns 33692 ns 21333
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:3/Target:0/Generator:0 76386 ns 74986 ns 8960
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:3/Target:0/Generator:0 200602 ns 200195 ns 3200
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:3/Target:0/Generator:0 804449 ns 802176 ns 896
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:3/Target:0/Generator:0 2230146 ns 2197266 ns 320
SearchBenchmark/Search/Rows:2/Columns:8192/Search:4/Target:0/Generator:0 39.3 ns 39.2 ns 17920000
SearchBenchmark/Search/Rows:4/Columns:8192/Search:4/Target:0/Generator:0 112 ns 112 ns 6400000
SearchBenchmark/Search/Rows:8/Columns:8192/Search:4/Target:0/Generator:0 310 ns 314 ns 2240000
SearchBenchmark/Search/Rows:16/Columns:8192/Search:4/Target:0/Generator:0 843 ns 854 ns 896000
SearchBenchmark/Search/Rows:32/Columns:8192/Search:4/Target:0/Generator:0 2379 ns 2354 ns 298667
SearchBenchmark/Search/Rows:64/Columns:8192/Search:4/Target:0/Generator:0 5730 ns 5720 ns 112000
SearchBenchmark/Search/Rows:128/Columns:8192/Search:4/Target:0/Generator:0 12565 ns 12556 ns 56000
SearchBenchmark/Search/Rows:256/Columns:8192/Search:4/Target:0/Generator:0 24920 ns 25112 ns 28000
SearchBenchmark/Search/Rows:512/Columns:8192/Search:4/Target:0/Generator:0 55463 ns 54688 ns 10000
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:4/Target:0/Generator:0 120611 ns 119978 ns 5600
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:4/Target:0/Generator:0 230801 ns 230164 ns 2987
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:4/Target:0/Generator:0 705006 ns 711178 ns 747
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:4/Target:0/Generator:0 1747131 ns 1717493 ns 373
SearchBenchmark/Search/Rows:2/Columns:8192/Search:0/Target:1/Generator:0 20654 ns 20403 ns 34462
SearchBenchmark/Search/Rows:4/Columns:8192/Search:0/Target:1/Generator:0 41193 ns 40806 ns 17231
SearchBenchmark/Search/Rows:8/Columns:8192/Search:0/Target:1/Generator:0 82431 ns 81609 ns 7467
SearchBenchmark/Search/Rows:16/Columns:8192/Search:0/Target:1/Generator:0 165041 ns 167411 ns 4480
SearchBenchmark/Search/Rows:32/Columns:8192/Search:0/Target:1/Generator:0 330003 ns 329641 ns 2133
SearchBenchmark/Search/Rows:64/Columns:8192/Search:0/Target:1/Generator:0 660575 ns 662667 ns 896
SearchBenchmark/Search/Rows:128/Columns:8192/Search:0/Target:1/Generator:0 1335292 ns 1349147 ns 498
SearchBenchmark/Search/Rows:256/Columns:8192/Search:0/Target:1/Generator:0 2673845 ns 2663352 ns 264
SearchBenchmark/Search/Rows:512/Columns:8192/Search:0/Target:1/Generator:0 5364294 ns 5312500 ns 100
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:0/Target:1/Generator:0 10661511 ns 10742188 ns 64
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:0/Target:1/Generator:0 21264024 ns 21139706 ns 34
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:0/Target:1/Generator:0 42489482 ns 43198529 ns 17
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:0/Target:1/Generator:0 84896678 ns 85069444 ns 9
SearchBenchmark/Search/Rows:2/Columns:8192/Search:1/Target:1/Generator:0 7.38 ns 7.32 ns 89600000
SearchBenchmark/Search/Rows:4/Columns:8192/Search:1/Target:1/Generator:0 13.2 ns 13.2 ns 49777778
SearchBenchmark/Search/Rows:8/Columns:8192/Search:1/Target:1/Generator:0 24.2 ns 24.0 ns 28000000
SearchBenchmark/Search/Rows:16/Columns:8192/Search:1/Target:1/Generator:0 49.8 ns 50.8 ns 14451613
SearchBenchmark/Search/Rows:32/Columns:8192/Search:1/Target:1/Generator:0 138 ns 138 ns 4977778
SearchBenchmark/Search/Rows:64/Columns:8192/Search:1/Target:1/Generator:0 393 ns 392 ns 1792000
SearchBenchmark/Search/Rows:128/Columns:8192/Search:1/Target:1/Generator:0 775 ns 767 ns 896000
SearchBenchmark/Search/Rows:256/Columns:8192/Search:1/Target:1/Generator:0 2474 ns 2511 ns 280000
SearchBenchmark/Search/Rows:512/Columns:8192/Search:1/Target:1/Generator:0 6122 ns 6138 ns 112000
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:1/Target:1/Generator:0 10303 ns 10463 ns 74667
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:1/Target:1/Generator:0 24959 ns 25111 ns 24889
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:1/Target:1/Generator:0 56122 ns 55804 ns 11200
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:1/Target:1/Generator:0 20583 ns 20403 ns 34462
SearchBenchmark/Search/Rows:2/Columns:8192/Search:2/Target:1/Generator:0 7.23 ns 7.15 ns 89600000
SearchBenchmark/Search/Rows:4/Columns:8192/Search:2/Target:1/Generator:0 13.7 ns 13.6 ns 44800000
SearchBenchmark/Search/Rows:8/Columns:8192/Search:2/Target:1/Generator:0 31.5 ns 31.1 ns 23578947
SearchBenchmark/Search/Rows:16/Columns:8192/Search:2/Target:1/Generator:0 108 ns 107 ns 6400000
SearchBenchmark/Search/Rows:32/Columns:8192/Search:2/Target:1/Generator:0 276 ns 276 ns 2488889
SearchBenchmark/Search/Rows:64/Columns:8192/Search:2/Target:1/Generator:0 793 ns 795 ns 1120000
SearchBenchmark/Search/Rows:128/Columns:8192/Search:2/Target:1/Generator:0 2031 ns 2040 ns 344615
SearchBenchmark/Search/Rows:256/Columns:8192/Search:2/Target:1/Generator:0 10220 ns 10254 ns 64000
SearchBenchmark/Search/Rows:512/Columns:8192/Search:2/Target:1/Generator:0 24818 ns 25111 ns 29867
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:2/Target:1/Generator:0 37253 ns 37667 ns 18667
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:2/Target:1/Generator:0 121550 ns 122070 ns 6400
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:2/Target:1/Generator:0 287246 ns 291561 ns 2358
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:2/Target:1/Generator:0 397134 ns 399013 ns 1723
SearchBenchmark/Search/Rows:2/Columns:8192/Search:3/Target:1/Generator:0 6.52 ns 6.56 ns 112000000
SearchBenchmark/Search/Rows:4/Columns:8192/Search:3/Target:1/Generator:0 7.80 ns 7.85 ns 89600000
SearchBenchmark/Search/Rows:8/Columns:8192/Search:3/Target:1/Generator:0 9.37 ns 9.42 ns 74666667
SearchBenchmark/Search/Rows:16/Columns:8192/Search:3/Target:1/Generator:0 10.9 ns 11.0 ns 64000000
SearchBenchmark/Search/Rows:32/Columns:8192/Search:3/Target:1/Generator:0 12.4 ns 12.6 ns 56000000
SearchBenchmark/Search/Rows:64/Columns:8192/Search:3/Target:1/Generator:0 15.0 ns 15.0 ns 44800000
SearchBenchmark/Search/Rows:128/Columns:8192/Search:3/Target:1/Generator:0 16.0 ns 16.0 ns 44800000
SearchBenchmark/Search/Rows:256/Columns:8192/Search:3/Target:1/Generator:0 17.4 ns 17.3 ns 40727273
SearchBenchmark/Search/Rows:512/Columns:8192/Search:3/Target:1/Generator:0 19.0 ns 18.8 ns 37333333
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:3/Target:1/Generator:0 20.8 ns 21.0 ns 32000000
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:3/Target:1/Generator:0 22.1 ns 22.0 ns 32000000
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:3/Target:1/Generator:0 23.4 ns 23.5 ns 29866667
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:3/Target:1/Generator:0 30.1 ns 30.5 ns 23578947
SearchBenchmark/Search/Rows:2/Columns:8192/Search:4/Target:1/Generator:0 7.16 ns 7.15 ns 89600000
SearchBenchmark/Search/Rows:4/Columns:8192/Search:4/Target:1/Generator:0 9.72 ns 9.63 ns 74666667
SearchBenchmark/Search/Rows:8/Columns:8192/Search:4/Target:1/Generator:0 13.4 ns 13.4 ns 56000000
SearchBenchmark/Search/Rows:16/Columns:8192/Search:4/Target:1/Generator:0 16.2 ns 16.5 ns 40727273
SearchBenchmark/Search/Rows:32/Columns:8192/Search:4/Target:1/Generator:0 19.2 ns 19.3 ns 37333333
SearchBenchmark/Search/Rows:64/Columns:8192/Search:4/Target:1/Generator:0 22.1 ns 22.0 ns 32000000
SearchBenchmark/Search/Rows:128/Columns:8192/Search:4/Target:1/Generator:0 26.1 ns 26.2 ns 28000000
SearchBenchmark/Search/Rows:256/Columns:8192/Search:4/Target:1/Generator:0 28.6 ns 28.3 ns 24888889
SearchBenchmark/Search/Rows:512/Columns:8192/Search:4/Target:1/Generator:0 31.6 ns 31.4 ns 22400000
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:4/Target:1/Generator:0 34.1 ns 33.8 ns 20363636
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:4/Target:1/Generator:0 66.6 ns 66.3 ns 8960000
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:4/Target:1/Generator:0 39.6 ns 39.0 ns 17230769
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:4/Target:1/Generator:0 42.9 ns 43.0 ns 16000000
SearchBenchmark/Search/Rows:2/Columns:8192/Search:0/Target:0/Generator:1 20591 ns 20508 ns 32000
SearchBenchmark/Search/Rows:4/Columns:8192/Search:0/Target:0/Generator:1 41224 ns 41713 ns 17231
SearchBenchmark/Search/Rows:8/Columns:8192/Search:0/Target:0/Generator:1 82745 ns 83705 ns 8960
SearchBenchmark/Search/Rows:16/Columns:8192/Search:0/Target:0/Generator:1 164932 ns 164958 ns 4073
SearchBenchmark/Search/Rows:32/Columns:8192/Search:0/Target:0/Generator:1 330651 ns 329998 ns 2036
SearchBenchmark/Search/Rows:64/Columns:8192/Search:0/Target:0/Generator:1 660871 ns 655692 ns 1120
SearchBenchmark/Search/Rows:128/Columns:8192/Search:0/Target:0/Generator:1 1331252 ns 1317771 ns 498
SearchBenchmark/Search/Rows:256/Columns:8192/Search:0/Target:0/Generator:1 2681703 ns 2722538 ns 264
SearchBenchmark/Search/Rows:512/Columns:8192/Search:0/Target:0/Generator:1 5314896 ns 5312500 ns 100
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:0/Target:0/Generator:1 10642816 ns 10742188 ns 64
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:0/Target:0/Generator:1 21207353 ns 20996094 ns 32
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:0/Target:0/Generator:1 42459171 ns 42279412 ns 17
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:0/Target:0/Generator:1 84907529 ns 84821429 ns 7
SearchBenchmark/Search/Rows:2/Columns:8192/Search:1/Target:0/Generator:1 29.8 ns 29.3 ns 22400000
SearchBenchmark/Search/Rows:4/Columns:8192/Search:1/Target:0/Generator:1 114 ns 115 ns 6400000
SearchBenchmark/Search/Rows:8/Columns:8192/Search:1/Target:0/Generator:1 268 ns 267 ns 2635294
SearchBenchmark/Search/Rows:16/Columns:8192/Search:1/Target:0/Generator:1 617 ns 614 ns 1120000
SearchBenchmark/Search/Rows:32/Columns:8192/Search:1/Target:0/Generator:1 1300 ns 1287 ns 497778
SearchBenchmark/Search/Rows:64/Columns:8192/Search:1/Target:0/Generator:1 2666 ns 2651 ns 224000
SearchBenchmark/Search/Rows:128/Columns:8192/Search:1/Target:0/Generator:1 5751 ns 5720 ns 112000
SearchBenchmark/Search/Rows:256/Columns:8192/Search:1/Target:0/Generator:1 17705 ns 17578 ns 37333
SearchBenchmark/Search/Rows:512/Columns:8192/Search:1/Target:0/Generator:1 53633 ns 54408 ns 11200
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:1/Target:0/Generator:1 115535 ns 114746 ns 6400
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:1/Target:0/Generator:1 247409 ns 251116 ns 2800
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:1/Target:0/Generator:1 512235 ns 518822 ns 1295
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:1/Target:0/Generator:1 227463 ns 229492 ns 3200
SearchBenchmark/Search/Rows:2/Columns:8192/Search:2/Target:0/Generator:1 36757 ns 36901 ns 19478
SearchBenchmark/Search/Rows:4/Columns:8192/Search:2/Target:0/Generator:1 36726 ns 36830 ns 18667
SearchBenchmark/Search/Rows:8/Columns:8192/Search:2/Target:0/Generator:1 36683 ns 36901 ns 19478
SearchBenchmark/Search/Rows:16/Columns:8192/Search:2/Target:0/Generator:1 36781 ns 35993 ns 18667
SearchBenchmark/Search/Rows:32/Columns:8192/Search:2/Target:0/Generator:1 36858 ns 36901 ns 19478
SearchBenchmark/Search/Rows:64/Columns:8192/Search:2/Target:0/Generator:1 37476 ns 36830 ns 18667
SearchBenchmark/Search/Rows:128/Columns:8192/Search:2/Target:0/Generator:1 38470 ns 38504 ns 18667
SearchBenchmark/Search/Rows:256/Columns:8192/Search:2/Target:0/Generator:1 41654 ns 41433 ns 16593
SearchBenchmark/Search/Rows:512/Columns:8192/Search:2/Target:0/Generator:1 55314 ns 54688 ns 10000
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:2/Target:0/Generator:1 66742 ns 65569 ns 11200
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:2/Target:0/Generator:1 144176 ns 144385 ns 4978
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:2/Target:0/Generator:1 309797 ns 313895 ns 2240
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:2/Target:0/Generator:1 416824 ns 423825 ns 1659
SearchBenchmark/Search/Rows:2/Columns:8192/Search:3/Target:0/Generator:1 34.9 ns 35.3 ns 20363636
SearchBenchmark/Search/Rows:4/Columns:8192/Search:3/Target:0/Generator:1 63.5 ns 62.8 ns 11200000
SearchBenchmark/Search/Rows:8/Columns:8192/Search:3/Target:0/Generator:1 89.2 ns 90.0 ns 7466667
SearchBenchmark/Search/Rows:16/Columns:8192/Search:3/Target:0/Generator:1 189 ns 188 ns 3733333
SearchBenchmark/Search/Rows:32/Columns:8192/Search:3/Target:0/Generator:1 298 ns 298 ns 2357895
SearchBenchmark/Search/Rows:64/Columns:8192/Search:3/Target:0/Generator:1 470 ns 471 ns 1493333
SearchBenchmark/Search/Rows:128/Columns:8192/Search:3/Target:0/Generator:1 790 ns 774 ns 746667
SearchBenchmark/Search/Rows:256/Columns:8192/Search:3/Target:0/Generator:1 1420 ns 1395 ns 448000
SearchBenchmark/Search/Rows:512/Columns:8192/Search:3/Target:0/Generator:1 2382 ns 2344 ns 280000
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:3/Target:0/Generator:1 4024 ns 3990 ns 172308
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:3/Target:0/Generator:1 6613 ns 6696 ns 112000
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:3/Target:0/Generator:1 10834 ns 10742 ns 64000
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:3/Target:0/Generator:1 16629 ns 16497 ns 40727
SearchBenchmark/Search/Rows:2/Columns:8192/Search:4/Target:0/Generator:1 239 ns 240 ns 2800000
SearchBenchmark/Search/Rows:4/Columns:8192/Search:4/Target:0/Generator:1 267 ns 267 ns 2635294
SearchBenchmark/Search/Rows:8/Columns:8192/Search:4/Target:0/Generator:1 286 ns 283 ns 2488889
SearchBenchmark/Search/Rows:16/Columns:8192/Search:4/Target:0/Generator:1 356 ns 361 ns 2036364
SearchBenchmark/Search/Rows:32/Columns:8192/Search:4/Target:0/Generator:1 455 ns 450 ns 1493333
SearchBenchmark/Search/Rows:64/Columns:8192/Search:4/Target:0/Generator:1 670 ns 663 ns 896000
SearchBenchmark/Search/Rows:128/Columns:8192/Search:4/Target:0/Generator:1 964 ns 952 ns 640000
SearchBenchmark/Search/Rows:256/Columns:8192/Search:4/Target:0/Generator:1 1526 ns 1507 ns 497778
SearchBenchmark/Search/Rows:512/Columns:8192/Search:4/Target:0/Generator:1 2464 ns 2455 ns 280000
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:4/Target:0/Generator:1 4230 ns 4238 ns 165926
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:4/Target:0/Generator:1 6934 ns 6975 ns 112000
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:4/Target:0/Generator:1 11382 ns 11161 ns 56000
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:4/Target:0/Generator:1 17997 ns 18032 ns 40727
SearchBenchmark/Search/Rows:2/Columns:8192/Search:0/Target:1/Generator:1 20601 ns 20856 ns 34462
SearchBenchmark/Search/Rows:4/Columns:8192/Search:0/Target:1/Generator:1 41213 ns 41713 ns 17231
SearchBenchmark/Search/Rows:8/Columns:8192/Search:0/Target:1/Generator:1 82512 ns 83705 ns 8960
SearchBenchmark/Search/Rows:16/Columns:8192/Search:0/Target:1/Generator:1 164956 ns 164958 ns 4073
SearchBenchmark/Search/Rows:32/Columns:8192/Search:0/Target:1/Generator:1 330178 ns 329641 ns 2133
SearchBenchmark/Search/Rows:64/Columns:8192/Search:0/Target:1/Generator:1 661273 ns 655692 ns 1120
SearchBenchmark/Search/Rows:128/Columns:8192/Search:0/Target:1/Generator:1 1332271 ns 1339286 ns 560
SearchBenchmark/Search/Rows:256/Columns:8192/Search:0/Target:1/Generator:1 2656639 ns 2663352 ns 264
SearchBenchmark/Search/Rows:512/Columns:8192/Search:0/Target:1/Generator:1 5345458 ns 5440848 ns 112
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:0/Target:1/Generator:1 10656244 ns 10625000 ns 75
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:0/Target:1/Generator:1 21253129 ns 21599265 ns 34
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:0/Target:1/Generator:1 42442800 ns 42968750 ns 16
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:0/Target:1/Generator:1 85390571 ns 87053571 ns 7
SearchBenchmark/Search/Rows:2/Columns:8192/Search:1/Target:1/Generator:1 30.6 ns 30.7 ns 22400000
SearchBenchmark/Search/Rows:4/Columns:8192/Search:1/Target:1/Generator:1 105 ns 105 ns 6400000
SearchBenchmark/Search/Rows:8/Columns:8192/Search:1/Target:1/Generator:1 271 ns 270 ns 2488889
SearchBenchmark/Search/Rows:16/Columns:8192/Search:1/Target:1/Generator:1 664 ns 656 ns 1120000
SearchBenchmark/Search/Rows:32/Columns:8192/Search:1/Target:1/Generator:1 1519 ns 1538 ns 497778
SearchBenchmark/Search/Rows:64/Columns:8192/Search:1/Target:1/Generator:1 3107 ns 3069 ns 224000
SearchBenchmark/Search/Rows:128/Columns:8192/Search:1/Target:1/Generator:1 6258 ns 6278 ns 112000
SearchBenchmark/Search/Rows:256/Columns:8192/Search:1/Target:1/Generator:1 13453 ns 13602 ns 44800
SearchBenchmark/Search/Rows:512/Columns:8192/Search:1/Target:1/Generator:1 52607 ns 51562 ns 10000
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:1/Target:1/Generator:1 114799 ns 114746 ns 6400
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:1/Target:1/Generator:1 242320 ns 239955 ns 2800
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:1/Target:1/Generator:1 516317 ns 515625 ns 1000
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:1/Target:1/Generator:1 264240 ns 260911 ns 2635
SearchBenchmark/Search/Rows:2/Columns:8192/Search:2/Target:1/Generator:1 36623 ns 35993 ns 18667
SearchBenchmark/Search/Rows:4/Columns:8192/Search:2/Target:1/Generator:1 37112 ns 36830 ns 18667
SearchBenchmark/Search/Rows:8/Columns:8192/Search:2/Target:1/Generator:1 36719 ns 36830 ns 18667
SearchBenchmark/Search/Rows:16/Columns:8192/Search:2/Target:1/Generator:1 37052 ns 37703 ns 19478
SearchBenchmark/Search/Rows:32/Columns:8192/Search:2/Target:1/Generator:1 36847 ns 36098 ns 19478
SearchBenchmark/Search/Rows:64/Columns:8192/Search:2/Target:1/Generator:1 37500 ns 37667 ns 18667
SearchBenchmark/Search/Rows:128/Columns:8192/Search:2/Target:1/Generator:1 38558 ns 38365 ns 17920
SearchBenchmark/Search/Rows:256/Columns:8192/Search:2/Target:1/Generator:1 41485 ns 41433 ns 16593
SearchBenchmark/Search/Rows:512/Columns:8192/Search:2/Target:1/Generator:1 52694 ns 53125 ns 10000
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:2/Target:1/Generator:1 80145 ns 80218 ns 8960
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:2/Target:1/Generator:1 151042 ns 153802 ns 4978
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:2/Target:1/Generator:1 300400 ns 299944 ns 2240
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:2/Target:1/Generator:1 392670 ns 392369 ns 1792
SearchBenchmark/Search/Rows:2/Columns:8192/Search:3/Target:1/Generator:1 35.4 ns 35.3 ns 19478261
SearchBenchmark/Search/Rows:4/Columns:8192/Search:3/Target:1/Generator:1 73.3 ns 73.2 ns 8960000
SearchBenchmark/Search/Rows:8/Columns:8192/Search:3/Target:1/Generator:1 166 ns 165 ns 4072727
SearchBenchmark/Search/Rows:16/Columns:8192/Search:3/Target:1/Generator:1 396 ns 401 ns 1792000
SearchBenchmark/Search/Rows:32/Columns:8192/Search:3/Target:1/Generator:1 799 ns 802 ns 896000
SearchBenchmark/Search/Rows:64/Columns:8192/Search:3/Target:1/Generator:1 1429 ns 1430 ns 448000
SearchBenchmark/Search/Rows:128/Columns:8192/Search:3/Target:1/Generator:1 2495 ns 2511 ns 280000
SearchBenchmark/Search/Rows:256/Columns:8192/Search:3/Target:1/Generator:1 4169 ns 4143 ns 165926
SearchBenchmark/Search/Rows:512/Columns:8192/Search:3/Target:1/Generator:1 7686 ns 7847 ns 89600
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:3/Target:1/Generator:1 13261 ns 13184 ns 49778
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:3/Target:1/Generator:1 22669 ns 22496 ns 29867
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:3/Target:1/Generator:1 38415 ns 38504 ns 18667
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:3/Target:1/Generator:1 79589 ns 80218 ns 8960
SearchBenchmark/Search/Rows:2/Columns:8192/Search:4/Target:1/Generator:1 221 ns 220 ns 3200000
SearchBenchmark/Search/Rows:4/Columns:8192/Search:4/Target:1/Generator:1 248 ns 246 ns 2800000
SearchBenchmark/Search/Rows:8/Columns:8192/Search:4/Target:1/Generator:1 341 ns 338 ns 2036364
SearchBenchmark/Search/Rows:16/Columns:8192/Search:4/Target:1/Generator:1 590 ns 586 ns 1120000
SearchBenchmark/Search/Rows:32/Columns:8192/Search:4/Target:1/Generator:1 1099 ns 1099 ns 640000
SearchBenchmark/Search/Rows:64/Columns:8192/Search:4/Target:1/Generator:1 1921 ns 1904 ns 344615
SearchBenchmark/Search/Rows:128/Columns:8192/Search:4/Target:1/Generator:1 3356 ns 3299 ns 203636
SearchBenchmark/Search/Rows:256/Columns:8192/Search:4/Target:1/Generator:1 5794 ns 5720 ns 112000
SearchBenchmark/Search/Rows:512/Columns:8192/Search:4/Target:1/Generator:1 9809 ns 9835 ns 74667
SearchBenchmark/Search/Rows:1024/Columns:8192/Search:4/Target:1/Generator:1 16220 ns 16497 ns 40727
SearchBenchmark/Search/Rows:2048/Columns:8192/Search:4/Target:1/Generator:1 27136 ns 27623 ns 24889
SearchBenchmark/Search/Rows:4096/Columns:8192/Search:4/Target:1/Generator:1 44049 ns 43945 ns 16000
SearchBenchmark/Search/Rows:8192/Columns:8192/Search:4/Target:1/Generator:1 72298 ns 71150 ns 11200

Первая часть

Генерация A

Target 2N + 1 Linear Target 2N + 1 Logarithmic

Target 16N + 1 Linear Target 16N + 1 Logarithmic

Генерация B

Target 2N + 1 Linear Target 2N + 1 Logarithmic

Target 16N + 1 Linear Target 16N + 1 Logarithmic

Вторая часть

Linear Logarithmic

About

Benchmark of search algorithms in a matrix

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published