Skip to content

Commit

Permalink
add benchmark (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
victor1234 authored Oct 27, 2021
1 parent b537e84 commit a0396e8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
3 changes: 2 additions & 1 deletion benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
add_subdirectory(image_processing_benchmarks)
add_subdirectory(image_processing_benchmarks)
add_subdirectory(transform)
2 changes: 2 additions & 0 deletions benchmarks/transform/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_executable(wavelet_benchmarks wavelet_benchmarks)
target_link_libraries(wavelet_benchmarks Catch2::Catch2)
19 changes: 19 additions & 0 deletions benchmarks/transform/wavelet_benchmarks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#define CATCH_CONFIG_MAIN

#define CATCH_CONFIG_ENABLE_BENCHMARKING

#include <catch2/catch.hpp>

#include <modules/transform/wavelet.hpp>

using T = double;


TEST_CASE("Daubechies matrix construction", "[transform][wavelet]")
{
BENCHMARK("Daubechies matrix construction")
{
return wavelet::DaubechiesMat<T>(48000, 2);
};
}

8 changes: 2 additions & 6 deletions modules/transform/wavelet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,10 +671,10 @@ blaze::CompressedMatrix<T> DaubechiesMat(size_t size, int order = 4)
assert(order % 2 == 0);

std::vector<T> c(order);
T coeff = 2 / sqrt(2);
constexpr T coeff = 2 / sqrt(2);
c = dbwavf<std::vector<T>>(order / 2, coeff);
for (size_t i = 0; i < c.size(); ++i) {
c[i] = c[i] * coeff;
c[i] *= coeff;
}

auto mat = blaze::CompressedMatrix<T>(size, size);
Expand All @@ -685,7 +685,6 @@ blaze::CompressedMatrix<T> DaubechiesMat(size_t size, int order = 4)
if (ci > c.size()) {
ci = 0;
}
std::cout << "ci" << ci << std::endl;
for (size_t a = 0; a < c.size(); ++a) {
if (ci >= c.size()) {
ci = ci % c.size();
Expand All @@ -697,7 +696,6 @@ blaze::CompressedMatrix<T> DaubechiesMat(size_t size, int order = 4)
}

mat.append(i, j, c[ci]);
std::cout << i << " " << j << " " << ci << " " << c[ci] << std::endl;

++ci;
}
Expand All @@ -713,7 +711,6 @@ blaze::CompressedMatrix<T> DaubechiesMat(size_t size, int order = 4)
if (ci > c.size()) {
ci = 0;
}
std::cout << "ci" << ci << std::endl;
for (size_t a = 0; a < c.size(); ++a) {
if (ci >= c.size()) {
ci = ci % c.size();
Expand All @@ -725,7 +722,6 @@ blaze::CompressedMatrix<T> DaubechiesMat(size_t size, int order = 4)
}

mat.append(size / 2 + i, j, c[order - 1 - ci]);
std::cout << i << " " << j << " " << ci << " " << c[ci] << std::endl;

++ci;
sign *= -1;
Expand Down

0 comments on commit a0396e8

Please sign in to comment.