![]() |
|
|||
File indexing completed on 2025-02-21 09:30:09
0001 /* 0002 Open Asset Import Library (assimp) 0003 ---------------------------------------------------------------------- 0004 0005 Copyright (c) 2006-2024, assimp team 0006 0007 0008 All rights reserved. 0009 0010 Redistribution and use of this software in source and binary forms, 0011 with or without modification, are permitted provided that the 0012 following conditions are met: 0013 0014 * Redistributions of source code must retain the above 0015 copyright notice, this list of conditions and the 0016 following disclaimer. 0017 0018 * Redistributions in binary form must reproduce the above 0019 copyright notice, this list of conditions and the 0020 following disclaimer in the documentation and/or other 0021 materials provided with the distribution. 0022 0023 * Neither the name of the assimp team, nor the names of its 0024 contributors may be used to endorse or promote products 0025 derived from this software without specific prior 0026 written permission of the assimp team. 0027 0028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 0029 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 0030 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 0031 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 0032 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 0033 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 0034 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0035 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0036 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0037 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0038 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0039 0040 ---------------------------------------------------------------------- 0041 */ 0042 0043 /** @file Profiler.h 0044 * @brief Utility to measure the respective runtime of each import step 0045 */ 0046 #pragma once 0047 #ifndef AI_INCLUDED_PROFILER_H 0048 #define AI_INCLUDED_PROFILER_H 0049 0050 #ifdef __GNUC__ 0051 # pragma GCC system_header 0052 #endif 0053 0054 #include <chrono> 0055 #include <assimp/DefaultLogger.hpp> 0056 #include <assimp/TinyFormatter.h> 0057 0058 #include <map> 0059 0060 namespace Assimp { 0061 namespace Profiling { 0062 0063 using namespace Formatter; 0064 0065 // ------------------------------------------------------------------------------------------------ 0066 /** Simple wrapper around boost::timer to simplify reporting. Timings are automatically 0067 * dumped to the log file. 0068 */ 0069 class Profiler { 0070 public: 0071 Profiler() = default; 0072 0073 0074 /** Start a named timer */ 0075 void BeginRegion(const std::string& region) { 0076 regions[region] = std::chrono::system_clock::now(); 0077 ASSIMP_LOG_DEBUG("START `",region,"`"); 0078 } 0079 0080 0081 /** End a specific named timer and write its end time to the log */ 0082 void EndRegion(const std::string& region) { 0083 RegionMap::const_iterator it = regions.find(region); 0084 if (it == regions.end()) { 0085 return; 0086 } 0087 0088 std::chrono::duration<double> elapsedSeconds = std::chrono::system_clock::now() - regions[region]; 0089 ASSIMP_LOG_DEBUG("END `",region,"`, dt= ", elapsedSeconds.count()," s"); 0090 } 0091 0092 private: 0093 typedef std::map<std::string,std::chrono::time_point<std::chrono::system_clock>> RegionMap; 0094 RegionMap regions; 0095 }; 0096 0097 } 0098 } 0099 0100 #endif // AI_INCLUDED_PROFILER_H 0101
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |