Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <iostream>
#include <shogun/lib/common.h>
#include <shogun/lib/SGVector.h>
#include <shogun/mathematics/Math.h>
#include <shogun/mathematics/linalg/linalg.h>
#include <hayai/hayai.hpp>
using namespace shogun;
using namespace Eigen;
struct data
{
const index_t size = 100;
SGVector<float64_t> v1;
SGVector<float64_t> v2;
data()
{
v1 = SGVector<float64_t>(size);
v2 = SGVector<float64_t>(size);
std::iota(v1.vector, v1.vector + v1.vlen, 1);
std::iota(v2.vector, v2.vector + v2.vlen, 1);
std::for_each(v1.vector, v1.vector + v1.vlen, [this](float64_t& v) { v /= size; });
std::for_each(v2.vector, v2.vector + v2.vlen, [this](float64_t& v) { v /= size; });
}
};
data d;
BENCHMARK(SGVector, linalg, 10, 1000000)
{
linalg::dot(d.v1, d.v2);
}
BENCHMARK(SGVector, cmath, 10, 1000000)
{
CMath::dot(d.v1.vector, d.v2.vector, d.size);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment