Browse Source

DebugTools: MSVC thanks for existing, again.

pull/432/merge
Vladimír Vondruš 6 years ago
parent
commit
433dd07d9c
  1. 9
      src/Magnum/DebugTools/Profiler.cpp
  2. 19
      src/Magnum/DebugTools/Profiler.h

9
src/Magnum/DebugTools/Profiler.cpp

@ -39,11 +39,14 @@ using namespace std::chrono;
namespace Magnum { namespace DebugTools {
/* MSVC complains about deprecated Section here */
CORRADE_IGNORE_DEPRECATED_PUSH
Profiler::Section Profiler::addSection(const std::string& name) {
CORRADE_ASSERT(!_enabled, "Profiler: cannot add section when profiling is enabled", 0);
_sections.push_back(name);
return _sections.size()-1;
}
CORRADE_IGNORE_DEPRECATED_POP
void Profiler::setMeasureDuration(std::size_t frames) {
CORRADE_ASSERT(!_enabled, "Profiler: cannot set measure duration when profiling is enabled", );
@ -61,6 +64,8 @@ void Profiler::disable() {
_enabled = false;
}
/* MSVC complains about deprecated Section here */
CORRADE_IGNORE_DEPRECATED_PUSH
void Profiler::start(Section section) {
if(!_enabled) return;
CORRADE_ASSERT(section < _sections.size(), "Profiler: unknown section passed to start()", );
@ -69,6 +74,7 @@ void Profiler::start(Section section) {
_currentSection = section;
}
CORRADE_IGNORE_DEPRECATED_POP
void Profiler::stop() {
if(!_enabled) return;
@ -117,7 +123,10 @@ void Profiler::printStatistics() {
std::vector<std::size_t> totalSorted(_sections.size());
std::iota(totalSorted.begin(), totalSorted.end(), 0);
/* MSVC complains about deprecated _totalData here (WTF) */
CORRADE_IGNORE_DEPRECATED_PUSH
std::sort(totalSorted.begin(), totalSorted.end(), [this](std::size_t i, std::size_t j){return _totalData[i] > _totalData[j];});
CORRADE_IGNORE_DEPRECATED_POP
Debug() << "Statistics for last" << _measureDuration << "frames:";
for(std::size_t i = 0; i != _sections.size(); ++i)

19
src/Magnum/DebugTools/Profiler.h

@ -126,9 +126,15 @@ class CORRADE_DEPRECATED("use FrameProfiler instead") MAGNUM_DEBUGTOOLS_EXPORT P
*
* @see @ref start()
*/
/* MSVC complains about deprecated Section here */
CORRADE_IGNORE_DEPRECATED_PUSH
static const Section otherSection = 0;
CORRADE_IGNORE_DEPRECATED_POP
/* MSVC complains about deprecated Section here */
CORRADE_IGNORE_DEPRECATED_PUSH
explicit Profiler(): _enabled(false), _measureDuration(60), _currentFrame(0), _frameCount(0), _sections{"Other"}, _currentSection(otherSection) {}
CORRADE_IGNORE_DEPRECATED_POP
/**
* @brief Set measure duration
@ -145,7 +151,10 @@ class CORRADE_DEPRECATED("use FrameProfiler instead") MAGNUM_DEBUGTOOLS_EXPORT P
* @attention This function cannot be called if profiling is enabled.
* @see @ref otherSection, @ref start(Section), @ref stop()
*/
/* MSVC complains about deprecated Section here */
CORRADE_IGNORE_DEPRECATED_PUSH
Section addSection(const std::string& name);
CORRADE_IGNORE_DEPRECATED_POP
/**
* @brief Whether profiling is enabled
@ -177,7 +186,10 @@ class CORRADE_DEPRECATED("use FrameProfiler instead") MAGNUM_DEBUGTOOLS_EXPORT P
* section.
* @see @ref otherSection, @ref start(Section)
*/
/* MSVC complains about deprecated Section here */
CORRADE_IGNORE_DEPRECATED_PUSH
void start(Section section);
CORRADE_IGNORE_DEPRECATED_POP
/**
* @brief Start profiling of "other" section
@ -185,7 +197,12 @@ class CORRADE_DEPRECATED("use FrameProfiler instead") MAGNUM_DEBUGTOOLS_EXPORT P
* Same as calling @cpp start(DebugTools::Profiler::otherSection) @ce.
* @note Does nothing if profiling is disabled.
*/
void start() { start(otherSection); }
void start() {
/* MSVC complains about deprecated Section here */
CORRADE_IGNORE_DEPRECATED_PUSH
start(otherSection);
CORRADE_IGNORE_DEPRECATED_POP
}
/**
* @brief Stop profiling

Loading…
Cancel
Save