-
Notifications
You must be signed in to change notification settings - Fork 0
/
CheckMateStats.cpp
117 lines (90 loc) · 4.1 KB
/
CheckMateStats.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//=--CheckMateStats.cpp--------------------------------------------------*- C++-*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// Implementation of all the methods in CheckMateStats.h
//===----------------------------------------------------------------------===//
#include "clang/CheckMate/CheckMateStats.h"
#include "clang/CheckMate/Utils.h"
#include <time.h>
void PerformanceStats::startCompileTime() { CompileTimeSt = clock(); }
void PerformanceStats::endCompileTime() {
CompileTime += getTimeSpentInSeconds(CompileTimeSt);
}
void PerformanceStats::startConstraintBuilderTime() {
ConstraintBuilderTimeSt = clock();
}
void PerformanceStats::endConstraintBuilderTime() {
ConstraintBuilderTime += getTimeSpentInSeconds(ConstraintBuilderTimeSt);
}
void PerformanceStats::startConstraintSolverTime() {
ConstraintSolverTimeSt = clock();
}
void PerformanceStats::endConstraintSolverTime() {
ConstraintSolverTime += getTimeSpentInSeconds(ConstraintSolverTimeSt);
}
void PerformanceStats::startArrayBoundsInferenceTime() {
ArrayBoundsInferenceTimeSt = clock();
}
void PerformanceStats::endArrayBoundsInferenceTime() {
ArrayBoundsInferenceTime += getTimeSpentInSeconds(ArrayBoundsInferenceTimeSt);
}
void PerformanceStats::startRewritingTime() { RewritingTimeSt = clock(); }
void PerformanceStats::endRewritingTime() {
RewritingTime += getTimeSpentInSeconds(RewritingTimeSt);
}
void PerformanceStats::startC4Countdown() { RewritingTimeSt = clock(); }
void PerformanceStats::endC4Countdown() {
RewritingTime += getTimeSpentInSeconds(RewritingTimeSt);
}
void PerformanceStats::startTotalTime() { TotalTimeSt = clock(); }
void PerformanceStats::endTotalTime() {
TotalTime += getTimeSpentInSeconds(TotalTimeSt);
}
void PerformanceStats::incrementNumAssumeBounds() { NumAssumeBoundsCasts++; }
void PerformanceStats::incrementNumCheckedCasts() { NumCheckedCasts++; }
void PerformanceStats::incrementNumWildCasts() { NumWildCasts++; }
void PerformanceStats::incrementNumFixedCasts() { NumFixedCasts++; }
void PerformanceStats::incrementNumITypes() { NumITypes++; }
void PerformanceStats::incrementNumCheckedRegions() { NumCheckedRegions++; }
void PerformanceStats::incrementNumUnCheckedRegions() { NumUnCheckedRegions++; }
void PerformanceStats::printPerformanceStats(llvm::raw_ostream &O,
bool JsonFormat) {
if (JsonFormat) {
O << "[";
O << "{\"TimeStats\": {\"TotalTime\":" << TotalTime;
O << ", \"ConstraintBuilderTime\":" << ConstraintBuilderTime;
O << ", \"ConstraintSolverTime\":" << ConstraintSolverTime;
O << ", \"ArrayBoundsInferenceTime\":" << ArrayBoundsInferenceTime;
O << ", \"RewritingTime\":" << RewritingTime;
O << "}},\n";
O << "{\"ReWriteStats\":{";
O << "\"NumAssumeBoundsCasts\":" << NumAssumeBoundsCasts;
O << ", \"NumCheckedCasts\":" << NumCheckedCasts;
O << ", \"NumWildCasts\":" << NumWildCasts;
O << ", \"NumFixedCasts\":" << NumFixedCasts;
O << ", \"NumITypes\":" << NumITypes;
O << ", \"NumCheckedRegions\":" << NumCheckedRegions;
O << ", \"NumUnCheckedRegions\":" << NumUnCheckedRegions;
O << "}}";
O << "]";
} else {
O << "TimeStats\n";
O << "TotalTime:" << TotalTime << "\n";
O << "ConstraintBuilderTime:" << ConstraintBuilderTime << "\n";
O << "ConstraintSolverTime:" << ConstraintSolverTime << "\n";
O << "ArrayBoundsInferenceTime:" << ArrayBoundsInferenceTime << "\n";
O << "RewritingTime:" << RewritingTime << "\n";
O << "ReWriteStats\n";
O << "NumAssumeBoundsCasts:" << NumAssumeBoundsCasts << "\n";
O << "NumCheckedCasts:" << NumCheckedCasts << "\n";
O << "NumWildCasts:" << NumWildCasts << "\n";
O << "NumFixedCasts:" << NumFixedCasts << "\n";
O << "NumITypes:" << NumITypes << "\n";
O << "NumCheckedRegions:" << NumCheckedRegions << "\n";
O << "NumUnCheckedRegions:" << NumUnCheckedRegions << "\n";
}
}