ClangTidyProfiling.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYPROFILING_H
  9. #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYPROFILING_H
  10. #include "llvm/ADT/StringMap.h"
  11. #include "llvm/Support/Chrono.h"
  12. #include "llvm/Support/Timer.h"
  13. #include <optional>
  14. #include <string>
  15. namespace llvm {
  16. class raw_ostream;
  17. } // namespace llvm
  18. namespace clang::tidy {
  19. class ClangTidyProfiling {
  20. public:
  21. struct StorageParams {
  22. llvm::sys::TimePoint<> Timestamp;
  23. std::string SourceFilename;
  24. std::string StoreFilename;
  25. StorageParams() = default;
  26. StorageParams(llvm::StringRef ProfilePrefix, llvm::StringRef SourceFile);
  27. };
  28. private:
  29. std::optional<llvm::TimerGroup> TG;
  30. std::optional<StorageParams> Storage;
  31. void printUserFriendlyTable(llvm::raw_ostream &OS);
  32. void printAsJSON(llvm::raw_ostream &OS);
  33. void storeProfileData();
  34. public:
  35. llvm::StringMap<llvm::TimeRecord> Records;
  36. ClangTidyProfiling() = default;
  37. ClangTidyProfiling(std::optional<StorageParams> Storage);
  38. ~ClangTidyProfiling();
  39. };
  40. } // namespace clang::tidy
  41. #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYPROFILING_H