Tesseract
Motion Planning Environment
Loading...
Searching...
No Matches
vhacdTimer.h
Go to the documentation of this file.
1/* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
2 All rights reserved.
3
4
5 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
6 following conditions are met:
7
8 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
9 disclaimer.
10
11 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
12 disclaimer in the documentation and/or other materials provided with the distribution.
13
14 3. The names of the contributors may not be used to endorse or promote products derived from this software without
15 specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25#pragma once
26
29
30#ifdef _WIN32
31#ifndef WIN32_LEAN_AND_MEAN
32#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
33#endif
34#include <windows.h>
35#elif __MACH__
36#include <mach/clock.h>
37#include <mach/mach.h>
38#else
39#include <sys/time.h>
40#include <time.h>
41#endif
42
43namespace tesseract_collision
44{
45namespace VHACD
46{
47#ifdef _WIN32
48class Timer
49{
50public:
51 Timer(void)
52 {
53 m_start.QuadPart = 0;
54 m_stop.QuadPart = 0;
55 QueryPerformanceFrequency(&m_freq);
56 };
57 ~Timer(void){};
58 void Tic() { QueryPerformanceCounter(&m_start); }
59 void Toc() { QueryPerformanceCounter(&m_stop); }
60 double GetElapsedTime() // in ms
61 {
62 LARGE_INTEGER delta;
63 delta.QuadPart = m_stop.QuadPart - m_start.QuadPart;
64 return (1000.0 * delta.QuadPart) / (double)m_freq.QuadPart;
65 }
66
67private:
68 LARGE_INTEGER m_start;
69 LARGE_INTEGER m_stop;
70 LARGE_INTEGER m_freq;
71};
72
73#elif __MACH__
74class Timer
75{
76public:
77 Timer(void)
78 {
79 memset(this, 0, sizeof(Timer));
80 host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &m_cclock);
81 };
82 ~Timer(void) { mach_port_deallocate(mach_task_self(), m_cclock); };
83 void Tic() { clock_get_time(m_cclock, &m_start); }
84 void Toc() { clock_get_time(m_cclock, &m_stop); }
85 double GetElapsedTime() // in ms
86 {
87 return 1000.0 * (m_stop.tv_sec - m_start.tv_sec + (1.0E-9) * (m_stop.tv_nsec - m_start.tv_nsec));
88 }
89
90private:
91 clock_serv_t m_cclock;
92 mach_timespec_t m_start;
93 mach_timespec_t m_stop;
94};
95#else
96class Timer
97{
98public:
99 Timer(void) { memset(this, 0, sizeof(Timer)); }
100 ~Timer(void) = default;
101 void Tic() { clock_gettime(CLOCK_REALTIME, &m_start); }
102 void Toc() { clock_gettime(CLOCK_REALTIME, &m_stop); }
103 double GetElapsedTime() // in ms
104 {
105 return 1000.0 * (m_stop.tv_sec - m_start.tv_sec + (1.0E-9) * (m_stop.tv_nsec - m_start.tv_nsec));
106 }
107
108private:
109 struct timespec m_start;
110 struct timespec m_stop;
111};
112#endif
113} // namespace VHACD
114} // namespace tesseract_collision
115
Definition: vhacdTimer.h:97
double GetElapsedTime()
Definition: vhacdTimer.h:103
struct timespec m_stop
Definition: vhacdTimer.h:110
Timer(void)
Definition: vhacdTimer.h:99
void Toc()
Definition: vhacdTimer.h:102
struct timespec m_start
Definition: vhacdTimer.h:109
void Tic()
Definition: vhacdTimer.h:101
Common Tesseract Macros.
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
Definition: macros.h:71
Definition: create_convex_hull.cpp:36
Definition: bullet_cast_bvh_manager.h:49