profiler_ScriptBinding.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifdef TORQUE_ENABLE_PROFILER
  23. extern Profiler *gProfiler;
  24. ConsoleFunctionGroupBegin( Profiler, "Profiler functionality.");
  25. /*! @defgroup ProfilerFunctions Profiler
  26. @ingroup TorqueScriptFunctions
  27. @{
  28. */
  29. /*! Enables (or disables) a marker for the profiler
  30. @param markerName The name of the marker to (un)set
  31. @param enable Boolean value. Set if true, unset if false
  32. @return No Return Value
  33. */
  34. ConsoleFunctionWithDocs(profilerMarkerEnable, ConsoleVoid, 3, 3, (string markerName, bool enable))
  35. {
  36. if(gProfiler)
  37. gProfiler->enableMarker(argv[1], dAtob(argv[2]));
  38. }
  39. /*! Use the profileEnable function to enable (or disable) engine profiling.
  40. @param enable A boolean value. If set to true and the engine was compiled with DEBUG specified, engine profiling is enabled, otherwise it is disabled.
  41. @return No return value.
  42. */
  43. ConsoleFunctionWithDocs(profilerEnable, ConsoleVoid, 2, 2, ( enable ))
  44. {
  45. if(gProfiler)
  46. gProfiler->enable(dAtob(argv[1]));
  47. }
  48. /*! Use the profilerDump function to dump engine profile statistics to the console.
  49. @return No return value
  50. */
  51. ConsoleFunctionWithDocs(profilerDump, ConsoleVoid, 1, 1, ())
  52. {
  53. if(gProfiler)
  54. gProfiler->dumpToConsole();
  55. }
  56. /*! Dump profiling stats to a file.
  57. */
  58. ConsoleFunctionWithDocs(profilerDumpToFile, ConsoleVoid, 2, 2, (string filename))
  59. {
  60. if(gProfiler)
  61. gProfiler->dumpToFile(argv[1]);
  62. }
  63. /*! Resets the profiler, clearing all of its data.
  64. */
  65. ConsoleFunctionWithDocs(profilerReset, ConsoleVoid, 1, 1, ())
  66. {
  67. if(gProfiler)
  68. gProfiler->reset();
  69. }
  70. ConsoleFunctionGroupEnd( Profiler );
  71. /*! @} */ // group ProfilerFunctions
  72. #endif