Last active
March 5, 2016 14:32
-
-
Save Saurabh7/9e83fca8763b45fd48cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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