Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Cazier
CGoGN
Commits
4f6dd032
Commit
4f6dd032
authored
Jan 25, 2012
by
Sylvain Thery
Browse files
easy measuring time. Let's go benchmarking !
Not yet tested on window (Linux/Mac:OK)
parent
2f60864c
Changes
1
Hide whitespace changes
Inline
Side-by-side
include/Utils/chrono.h
0 → 100644
View file @
4f6dd032
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.u-strasbg.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef _CGOGN_CHRONO_H_
#define _CGOGN_CHRONO_H_
#if defined WIN32
#include
<windows.h>
#else
#include
<sys/time.h>
#endif
namespace
CGoGN
{
namespace
Utils
{
#if defined _WIN32
class
Chrono
{
ULARGE_INTEGER
m_begin
;
ULARGE_INTEGER
m_end
;
public:
/// start the chrono
inline
void
start
()
{
FILETIME
ttmp
=
{
0
,
0
};
::
GetSystemTimeAsFileTime
(
&
ttmp
);
m_begin
.
HighPart
=
ttmp
.
dwHighDateTime
;
m_begin
.
LowPart
=
ttmp
.
dwLowDateTime
;
}
/// return elapsed time since start (cumulative if several calls)
inline
int
elapsed
()
{
FILETIME
ttmp
=
{
0
,
0
};
::
GetSystemTimeAsFileTime
(
&
ttmp
);
m_end
.
HighPart
=
ttmp
.
dwHighDateTime
;
m_end
.
LowPart
=
ttmp
.
dwLowDateTime
;
return
int
((
double
(
m_end
.
QuadPart
-
m_begin
.
QuadPart
)
/
10000.0
));
}
};
#else
/**
* class for each time mesuring
*/
class
Chrono
{
struct
timeval
m_start
;
struct
timeval
m_end
;
public:
/// start the chrono
inline
void
start
()
{
gettimeofday
(
&
m_start
,
NULL
)
;
}
/// return elapsed time since start (cumulative if several calls)
inline
int
elapsed
()
{
gettimeofday
(
&
m_end
,
NULL
)
;
long
seconds
=
m_end
.
tv_sec
-
m_start
.
tv_sec
;
long
useconds
=
m_end
.
tv_usec
-
m_start
.
tv_usec
;
return
int
((
seconds
*
1000
+
useconds
/
1000.0
)
+
0.5
);
}
};
#endif
}
}
#endif
/* _CGOGN_CHRONO_H_ */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment