mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 19:59:05 +08:00
clean #defined tokens, and use clock_gettime for the real time
This commit is contained in:
parent
ff6b94d6d0
commit
b0ffd9bf04
@ -1,7 +1,7 @@
|
|||||||
// This file is part of Eigen, a lightweight C++ template library
|
// This file is part of Eigen, a lightweight C++ template library
|
||||||
// for linear algebra.
|
// for linear algebra.
|
||||||
//
|
//
|
||||||
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
|
// Copyright (C) 2008-2010 Gael Guennebaud <g.gael@free.fr>
|
||||||
// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
|
// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
|
||||||
//
|
//
|
||||||
// Eigen is free software; you can redistribute it and/or
|
// Eigen is free software; you can redistribute it and/or
|
||||||
@ -27,22 +27,19 @@
|
|||||||
#define EIGEN_BENCH_TIMERR_H
|
#define EIGEN_BENCH_TIMERR_H
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
#ifndef NOMINMAX
|
# ifndef NOMINMAX
|
||||||
#define NOMINMAX
|
# define NOMINMAX
|
||||||
#endif
|
# define EIGEN_BT_UNDEF_NOMINMAX
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
# endif
|
||||||
#define WIN32_LEAN_AND_MEAN
|
# ifndef WIN32_LEAN_AND_MEAN
|
||||||
#endif
|
# define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
# define EIGEN_BT_UNDEF_WIN32_LEAN_AND_MEAN
|
||||||
|
# endif
|
||||||
|
# include <windows.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/time.h>
|
# include <unistd.h>
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <numeric>
|
|
||||||
#include <Eigen/Core>
|
#include <Eigen/Core>
|
||||||
|
|
||||||
namespace Eigen
|
namespace Eigen
|
||||||
@ -131,14 +128,13 @@ public:
|
|||||||
inline double getRealTime()
|
inline double getRealTime()
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
GetSystemTime(&st);
|
GetSystemTime(&st);
|
||||||
return (double)st.wSecond + 1.e-3 * (double)st.wMilliseconds;
|
return (double)st.wSecond + 1.e-3 * (double)st.wMilliseconds;
|
||||||
#else
|
#else
|
||||||
struct timeval tv;
|
timespec ts;
|
||||||
struct timezone tz;
|
clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
gettimeofday(&tv, &tz);
|
return double(ts.tv_sec) + 1e-9 * double(ts.tv_nsec);
|
||||||
return (double)tv.tv_sec + 1.e-6 * (double)tv.tv_usec;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,4 +162,15 @@ protected:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clean #defined tokens
|
||||||
|
#ifdef EIGEN_BT_UNDEF_NOMINMAX
|
||||||
|
# undef EIGEN_BT_UNDEF_NOMINMAX
|
||||||
|
# undef NOMINMAX
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef EIGEN_BT_UNDEF_WIN32_LEAN_AND_MEAN
|
||||||
|
# undef EIGEN_BT_UNDEF_WIN32_LEAN_AND_MEAN
|
||||||
|
# undef WIN32_LEAN_AND_MEAN
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // EIGEN_BENCH_TIMERR_H
|
#endif // EIGEN_BENCH_TIMERR_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user