| 1 | //===--- ClangTidyProfiling.h - clang-tidy ----------------------*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYPROFILING_H |
| 10 | #define |
| 11 | |
| 12 | #include "llvm/ADT/StringMap.h" |
| 13 | #include "llvm/Support/Chrono.h" |
| 14 | #include "llvm/Support/Timer.h" |
| 15 | #include <optional> |
| 16 | #include <string> |
| 17 | |
| 18 | namespace llvm { |
| 19 | class raw_ostream; |
| 20 | } // namespace llvm |
| 21 | |
| 22 | namespace clang::tidy { |
| 23 | |
| 24 | class ClangTidyProfiling { |
| 25 | public: |
| 26 | struct StorageParams { |
| 27 | llvm::sys::TimePoint<> Timestamp; |
| 28 | std::string SourceFilename; |
| 29 | std::string StoreFilename; |
| 30 | |
| 31 | StorageParams() = default; |
| 32 | |
| 33 | StorageParams(llvm::StringRef ProfilePrefix, llvm::StringRef SourceFile); |
| 34 | }; |
| 35 | |
| 36 | private: |
| 37 | std::optional<StorageParams> Storage; |
| 38 | |
| 39 | void printUserFriendlyTable(llvm::raw_ostream &OS, llvm::TimerGroup &TG); |
| 40 | void printAsJSON(llvm::raw_ostream &OS, llvm::TimerGroup &TG); |
| 41 | void storeProfileData(llvm::TimerGroup &TG); |
| 42 | |
| 43 | public: |
| 44 | llvm::StringMap<llvm::TimeRecord> Records; |
| 45 | |
| 46 | ClangTidyProfiling() = default; |
| 47 | |
| 48 | ClangTidyProfiling(std::optional<StorageParams> Storage); |
| 49 | |
| 50 | ~ClangTidyProfiling(); |
| 51 | }; |
| 52 | |
| 53 | } // namespace clang::tidy |
| 54 | |
| 55 | #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYPROFILING_H |
| 56 | |