From 56d434132ed76cdfb34ce85e295a743f1b3d5231 Mon Sep 17 00:00:00 2001 From: Daniel Buckmaster Date: Tue, 15 Jul 2014 12:44:10 +0200 Subject: [PATCH] Added optimistic profiler test. --- Engine/source/platform/test/profilerTest.cpp | 49 ++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Engine/source/platform/test/profilerTest.cpp diff --git a/Engine/source/platform/test/profilerTest.cpp b/Engine/source/platform/test/profilerTest.cpp new file mode 100644 index 000000000..64ccc36d3 --- /dev/null +++ b/Engine/source/platform/test/profilerTest.cpp @@ -0,0 +1,49 @@ +//----------------------------------------------------------------------------- +// Copyright (c) 2014 GarageGames, LLC +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +//----------------------------------------------------------------------------- + +#ifdef TORQUE_TESTS_ENABLED +#include "platform/platform.h" // Allows us to see TORQUE_ENABLE_PROFILER + +#ifdef TORQUE_ENABLE_PROFILER +#include "testing/unitTesting.h" +#include "platform/profiler.h" + +TEST(Profiler, ProfileStartEnd) +{ + PROFILE_START(ProfileStartEndTest); + // Do work. + if(true) + { + PROFILE_END(ProfileStartEndTest); + return; + } + PROFILE_END(ProfileStartEndTest); +} + +TEST(Profiler, ProfileScope) +{ + PROFILE_SCOPE(ScopedProfilerTest); + // Do work and return whenever you want. +} + +#endif +#endif \ No newline at end of file