BaseProfilingCategory.h (2594B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 2 * vim: set ts=8 sts=4 et sw=4 tw=99: 3 * This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef BaseProfilingCategory_h 8 #define BaseProfilingCategory_h 9 10 #include "mozilla/Span.h" 11 #include "mozilla/Types.h" 12 13 #include <cstdint> 14 15 #include "mozilla/ProfilingCategoryList.h" 16 17 namespace mozilla { 18 namespace baseprofiler { 19 20 // clang-format off 21 22 // An enum that lists all possible category pairs in one list. 23 // This is the enum that is used in profiler stack labels. Having one list that 24 // includes subcategories from all categories in one list allows assigning the 25 // category pair to a stack label with just one number. 26 #define CATEGORY_ENUM_BEGIN_CATEGORY(name, labelAsString, color) 27 #define CATEGORY_ENUM_SUBCATEGORY(supercategory, name, labelAsString) name, 28 #define CATEGORY_ENUM_END_CATEGORY 29 enum class ProfilingCategoryPair : uint32_t { 30 MOZ_PROFILING_CATEGORY_LIST(CATEGORY_ENUM_BEGIN_CATEGORY, 31 CATEGORY_ENUM_SUBCATEGORY, 32 CATEGORY_ENUM_END_CATEGORY) 33 COUNT, 34 LAST = COUNT - 1, 35 }; 36 #undef CATEGORY_ENUM_BEGIN_CATEGORY 37 #undef CATEGORY_ENUM_SUBCATEGORY 38 #undef CATEGORY_ENUM_END_CATEGORY 39 40 // An enum that lists just the categories without their subcategories. 41 #define SUPERCATEGORY_ENUM_BEGIN_CATEGORY(name, labelAsString, color) name, 42 #define SUPERCATEGORY_ENUM_SUBCATEGORY(supercategory, name, labelAsString) 43 #define SUPERCATEGORY_ENUM_END_CATEGORY 44 enum class ProfilingCategory : uint32_t { 45 MOZ_PROFILING_CATEGORY_LIST(SUPERCATEGORY_ENUM_BEGIN_CATEGORY, 46 SUPERCATEGORY_ENUM_SUBCATEGORY, 47 SUPERCATEGORY_ENUM_END_CATEGORY) 48 COUNT, 49 LAST = COUNT - 1, 50 }; 51 #undef SUPERCATEGORY_ENUM_BEGIN_CATEGORY 52 #undef SUPERCATEGORY_ENUM_SUBCATEGORY 53 #undef SUPERCATEGORY_ENUM_END_CATEGORY 54 55 // clang-format on 56 57 struct ProfilingCategoryInfo { 58 const char* mName; 59 const char* mColor; 60 const mozilla::Span<const char* const> mSubcategoryNames; 61 }; 62 63 struct ProfilingCategoryPairInfo { 64 ProfilingCategory mCategory; 65 uint32_t mSubcategoryIndex; 66 const char* mLabel; 67 }; 68 69 MFBT_API mozilla::Span<const ProfilingCategoryInfo> GetProfilingCategoryList(); 70 71 MFBT_API const ProfilingCategoryPairInfo& GetProfilingCategoryPairInfo( 72 ProfilingCategoryPair aCategoryPair); 73 74 } // namespace baseprofiler 75 } // namespace mozilla 76 77 #endif /* BaseProfilingCategory_h */