Skip to content

Instantly share code, notes, and snippets.

@Saurabh7
Last active March 5, 2016 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Saurabh7/9e83fca8763b45fd48cf to your computer and use it in GitHub Desktop.
Save Saurabh7/9e83fca8763b45fd48cf to your computer and use it in GitHub Desktop.
#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