Roman Lebedev | 1215251 | 2018-05-08 13:14:21 +0000 | [diff] [blame] | 1 | //===--- ClangTidyProfiling.h - clang-tidy ----------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYPROFILING_H |
| 11 | #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYPROFILING_H |
| 12 | |
Roman Lebedev | a87f1d0 | 2018-06-06 15:07:51 +0000 | [diff] [blame] | 13 | #include "llvm/ADT/Optional.h" |
Roman Lebedev | 1215251 | 2018-05-08 13:14:21 +0000 | [diff] [blame] | 14 | #include "llvm/ADT/StringMap.h" |
Roman Lebedev | a87f1d0 | 2018-06-06 15:07:51 +0000 | [diff] [blame] | 15 | #include "llvm/Support/Chrono.h" |
Roman Lebedev | 1215251 | 2018-05-08 13:14:21 +0000 | [diff] [blame] | 16 | #include "llvm/Support/Timer.h" |
| 17 | #include "llvm/Support/raw_ostream.h" |
Roman Lebedev | a87f1d0 | 2018-06-06 15:07:51 +0000 | [diff] [blame] | 18 | #include <string> |
Roman Lebedev | 1215251 | 2018-05-08 13:14:21 +0000 | [diff] [blame] | 19 | #include <utility> |
| 20 | #include <vector> |
| 21 | |
| 22 | namespace clang { |
| 23 | namespace tidy { |
| 24 | |
| 25 | class ClangTidyProfiling { |
Roman Lebedev | a87f1d0 | 2018-06-06 15:07:51 +0000 | [diff] [blame] | 26 | public: |
| 27 | struct StorageParams { |
| 28 | llvm::sys::TimePoint<> Timestamp; |
| 29 | std::string SourceFilename; |
| 30 | std::string StoreFilename; |
Roman Lebedev | 1215251 | 2018-05-08 13:14:21 +0000 | [diff] [blame] | 31 | |
Roman Lebedev | a87f1d0 | 2018-06-06 15:07:51 +0000 | [diff] [blame] | 32 | StorageParams() = default; |
Roman Lebedev | 1215251 | 2018-05-08 13:14:21 +0000 | [diff] [blame] | 33 | |
Roman Lebedev | a87f1d0 | 2018-06-06 15:07:51 +0000 | [diff] [blame] | 34 | StorageParams(llvm::StringRef ProfilePrefix, llvm::StringRef SourceFile); |
| 35 | }; |
| 36 | |
| 37 | private: |
| 38 | llvm::Optional<llvm::TimerGroup> TG; |
| 39 | |
| 40 | llvm::Optional<StorageParams> Storage; |
| 41 | |
| 42 | void printUserFriendlyTable(llvm::raw_ostream &OS); |
| 43 | void printAsJSON(llvm::raw_ostream &OS); |
| 44 | |
| 45 | void storeProfileData(); |
Roman Lebedev | 1215251 | 2018-05-08 13:14:21 +0000 | [diff] [blame] | 46 | |
| 47 | public: |
| 48 | llvm::StringMap<llvm::TimeRecord> Records; |
| 49 | |
Roman Lebedev | a87f1d0 | 2018-06-06 15:07:51 +0000 | [diff] [blame] | 50 | ClangTidyProfiling() = default; |
| 51 | |
| 52 | ClangTidyProfiling(llvm::Optional<StorageParams> Storage); |
| 53 | |
Roman Lebedev | 1215251 | 2018-05-08 13:14:21 +0000 | [diff] [blame] | 54 | ~ClangTidyProfiling(); |
| 55 | }; |
| 56 | |
| 57 | } // end namespace tidy |
| 58 | } // end namespace clang |
| 59 | |
| 60 | #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYPROFILING_H |