mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Clang-format tests, examples, libraries, benchmarks, etc.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
3252ecc7a4
commit
46e9cdb7fe
@@ -16,23 +16,20 @@
|
||||
#include <utility>
|
||||
|
||||
template <typename MatrixType>
|
||||
void copy_matrix(MatrixType& m)
|
||||
{
|
||||
void copy_matrix(MatrixType& m) {
|
||||
MatrixType tmp(m);
|
||||
m = tmp;
|
||||
}
|
||||
|
||||
template <typename MatrixType>
|
||||
void move_matrix(MatrixType&& m)
|
||||
{
|
||||
void move_matrix(MatrixType&& m) {
|
||||
MatrixType tmp(std::move(m));
|
||||
m = std::move(tmp);
|
||||
}
|
||||
|
||||
template<typename Scalar>
|
||||
void bench(const std::string& label)
|
||||
{
|
||||
using MatrixType = Eigen::Matrix<Eigen::MovableScalar<Scalar>,1,10>;
|
||||
template <typename Scalar>
|
||||
void bench(const std::string& label) {
|
||||
using MatrixType = Eigen::Matrix<Eigen::MovableScalar<Scalar>, 1, 10>;
|
||||
Eigen::BenchTimer t;
|
||||
|
||||
int tries = 10;
|
||||
@@ -42,16 +39,14 @@ void bench(const std::string& label)
|
||||
MatrixType dest;
|
||||
|
||||
BENCH(t, tries, rep, copy_matrix(data));
|
||||
std::cout << label << " copy semantics: " << 1e3*t.best(Eigen::CPU_TIMER) << " ms" << std::endl;
|
||||
std::cout << label << " copy semantics: " << 1e3 * t.best(Eigen::CPU_TIMER) << " ms" << std::endl;
|
||||
|
||||
BENCH(t, tries, rep, move_matrix(std::move(data)));
|
||||
std::cout << label << " move semantics: " << 1e3*t.best(Eigen::CPU_TIMER) << " ms" << std::endl;
|
||||
std::cout << label << " move semantics: " << 1e3 * t.best(Eigen::CPU_TIMER) << " ms" << std::endl;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int main() {
|
||||
bench<float>("float");
|
||||
bench<double>("double");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user