Static Value-Flow Analysis
Loading...
Searching...
No Matches
MTAStat.h
Go to the documentation of this file.
1//===- MTAStat.h -- Statistics for MTA-------------//
2//
3// SVF: Static Value-Flow Analysis
4//
5// Copyright (C) <2013-> <Yulei Sui>
6//
7
8// This program is free software: you can redistribute it and/or modify
9// it under the terms of the GNU Affero General Public License as published by
10// the Free Software Foundation, either version 3 of the License, or
11// (at your option) any later version.
12
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU Affero General Public License for more details.
17
18// You should have received a copy of the GNU Affero General Public License
19// along with this program. If not, see <http://www.gnu.org/licenses/>.
20//
21//===----------------------------------------------------------------------===//
22
23/*
24 * MTAStat.h
25 *
26 * Created on: Jun 23, 2015
27 * Author: Yulei Sui, Peng Di
28 */
29
30#ifndef MTASTAT_H_
31#define MTASTAT_H_
32
33#include "Util/PTAStat.h"
34#include "Util/Options.h"
35#include "Util/SVFUtil.h"
36
37#include <chrono>
38#include <iomanip>
39#include <sstream>
40
41namespace SVF
42{
43
46inline bool isMTAStatEnabled()
47{
49}
50
52{
53public:
54 explicit ScopedPhaseTimer(const char* phaseName)
58 {
59 if (enabled)
60 {
61 SVFUtil::outs() << "[TIMER] Phase: " << name << " - started\n";
62 SVFUtil::outs().flush();
63 }
64 }
65
67 {
68 if (!enabled)
69 return;
70
71 const auto end = std::chrono::steady_clock::now();
72 const double milliseconds =
73 std::chrono::duration_cast<std::chrono::duration<double, std::milli>>(
74 end - start).count();
75 std::ostringstream elapsed;
76 elapsed << std::fixed << std::setprecision(2) << milliseconds << " ms";
77 if (milliseconds >= 1000.0)
78 elapsed << " (" << std::fixed << std::setprecision(2)
79 << (milliseconds / 1000.0) << " s)";
80 SVFUtil::outs() << "[TIMER] Phase: " << name << " - finished in "
81 << elapsed.str() << "\n";
82 SVFUtil::outs().flush();
83 }
84
85private:
86 const char* name;
87 const bool enabled;
88 std::chrono::steady_clock::time_point start;
89};
90
91class ThreadCallGraph;
92class TCT;
93class MHP;
94class LockAnalysis;
95class MTAAnnotator;
99class MTAStat : public PTAStat
100{
101
102public:
105 {
106 }
110 void performTCTStat(TCT* tct);
111
112 double TCTTime;
113 double MHPTime;
115};
116
117} // End namespace SVF
118
119#endif /* MTASTAT_H_ */
int count
Definition cJSON.h:216
bool isSet(void) const
Definition MHP.h:52
MTAStat()
Constructor.
Definition MTAStat.h:104
void performTCTStat(TCT *tct)
Statistics for thread creation tree.
Definition MTAStat.cpp:92
void performThreadCallGraphStat(ThreadCallGraph *tcg)
Statistics for thread call graph.
Definition MTAStat.cpp:44
double TCTTime
Definition MTAStat.h:112
double AnnotationTime
Definition MTAStat.h:114
double MHPTime
Definition MTAStat.h:113
static const Option< bool > PStat
Definition Options.h:115
const bool enabled
Definition MTAStat.h:87
ScopedPhaseTimer(const char *phaseName)
Definition MTAStat.h:54
std::chrono::steady_clock::time_point start
Definition MTAStat.h:88
const char * name
Definition MTAStat.h:86
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:52
for isBitcode
Definition BasicTypes.h:70
bool isMTAStatEnabled()
Definition MTAStat.h:46
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76