summaryrefslogtreecommitdiffstats
path: root/xbmc/utils/Stopwatch.cpp
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
committermanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
commitbe933ef2241d79558f91796cc5b3a161f72ebf9c (patch)
treefe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/utils/Stopwatch.cpp
parent5f8335c1e49ce108ef3481863833c98efa00411b (diff)
downloadkodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip
sync with upstream
Diffstat (limited to 'xbmc/utils/Stopwatch.cpp')
-rw-r--r--xbmc/utils/Stopwatch.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/xbmc/utils/Stopwatch.cpp b/xbmc/utils/Stopwatch.cpp
new file mode 100644
index 0000000..bec498f
--- /dev/null
+++ b/xbmc/utils/Stopwatch.cpp
@@ -0,0 +1,47 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#include "Stopwatch.h"
10#if defined(TARGET_POSIX)
11#include "threads/SystemClock.h"
12#if !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD)
13#include <sys/sysinfo.h>
14#endif
15#endif
16#include "utils/TimeUtils.h"
17
18CStopWatch::CStopWatch(bool useFrameTime /*=false*/)
19{
20 m_timerPeriod = 0.0f;
21 m_startTick = 0;
22 m_stopTick = 0;
23 m_isRunning = false;
24 m_useFrameTime = useFrameTime;
25
26#ifdef TARGET_POSIX
27 m_timerPeriod = 1.0f / 1000.0f; // we want seconds
28#else
29 if (m_useFrameTime)
30 m_timerPeriod = 1.0f / 1000.0f; //frametime is in milliseconds
31 else
32 m_timerPeriod = 1.0f / (float)CurrentHostFrequency();
33#endif
34}
35
36CStopWatch::~CStopWatch() = default;
37
38int64_t CStopWatch::GetTicks() const
39{
40 if (m_useFrameTime)
41 return CTimeUtils::GetFrameTime();
42#ifndef TARGET_POSIX
43 return CurrentHostCounter();
44#else
45 return XbmcThreads::SystemClockMillis();
46#endif
47}