Static Value-Flow Analysis
Public Member Functions | Public Attributes | List of all members
SVF::AEStat Class Reference

AEStat: Statistic for AE. More...

#include <AbstractInterpretation.h>

Inheritance diagram for SVF::AEStat:
SVF::SVFStat

Public Member Functions

void countStateSize ()
 
 AEStat (AbstractInterpretation *ae)
 
 ~AEStat ()
 
std::string getMemUsage ()
 
void finializeStat ()
 
void performStat () override
 
u32_tgetFunctionTrace ()
 
u32_tgetBlockTrace ()
 
u32_tgetICFGNodeTrace ()
 
- Public Member Functions inherited from SVF::SVFStat
 SVFStat ()
 
virtual ~SVFStat ()
 
virtual void startClk ()
 
virtual void endClk ()
 
virtual void printStat (std::string str="")
 
virtual void performStatPerQuery (NodeID)
 
virtual void printStatPerQuery (NodeID, const PointsTo &)
 
virtual void callgraphStat ()
 

Public Attributes

AbstractInterpretation_ae
 
s32_t count {0}
 
std::string memory_usage
 
std::string memUsage
 
- Public Attributes inherited from SVF::SVFStat
NUMStatMap generalNumMap
 
NUMStatMap PTNumStatMap
 
TIMEStatMap timeStatMap
 
double startTime
 
double endTime
 

Additional Inherited Members

- Public Types inherited from SVF::SVFStat
enum  ClockType { Wall , CPU }
 
typedef OrderedMap< std::string, u32_tNUMStatMap
 
typedef OrderedMap< std::string, double > TIMEStatMap
 
- Static Public Member Functions inherited from SVF::SVFStat
static double getClk (bool mark=false)
 
- Static Public Attributes inherited from SVF::SVFStat
static bool printGeneralStats = true
 SVF's general statistics are only printed once even if you run multiple anayses. More...
 
static double timeOfBuildingLLVMModule = 0
 
static double timeOfBuildingSymbolTable = 0
 
static double timeOfBuildingSVFIR = 0
 

Detailed Description

AEStat: Statistic for AE.

Definition at line 48 of file AbstractInterpretation.h.

Constructor & Destructor Documentation

◆ AEStat()

SVF::AEStat::AEStat ( AbstractInterpretation ae)
inline

Definition at line 52 of file AbstractInterpretation.h.

52  : _ae(ae)
53  {
54  startTime = getClk(true);
55  }
AbstractInterpretation * _ae
double startTime
Definition: SVFStat.h:80
static double getClk(bool mark=false)
Definition: SVFStat.cpp:47

◆ ~AEStat()

SVF::AEStat::~AEStat ( )
inline

Definition at line 56 of file AbstractInterpretation.h.

57  {
58  }

Member Function Documentation

◆ countStateSize()

void AEStat::countStateSize ( )

Definition at line 826 of file AbstractInterpretation.cpp.

827 {
828  if (count == 0)
829  {
830  generalNumMap["ES_Var_AVG_Num"] = 0;
831  generalNumMap["ES_Loc_AVG_Num"] = 0;
832  generalNumMap["ES_Var_Addr_AVG_Num"] = 0;
833  generalNumMap["ES_Loc_Addr_AVG_Num"] = 0;
834  }
835  ++count;
836 }
NUMStatMap generalNumMap
Definition: SVFStat.h:76

◆ finializeStat()

void AEStat::finializeStat ( )

Definition at line 838 of file AbstractInterpretation.cpp.

839 {
840  memUsage = getMemUsage();
841  if (count > 0)
842  {
843  generalNumMap["ES_Var_AVG_Num"] /= count;
844  generalNumMap["ES_Loc_AVG_Num"] /= count;
845  generalNumMap["ES_Var_Addr_AVG_Num"] /= count;
846  generalNumMap["ES_Loc_Addr_AVG_Num"] /= count;
847  }
848  generalNumMap["SVF_STMT_NUM"] = count;
849  generalNumMap["ICFG_Node_Num"] = _ae->svfir->getICFG()->nodeNum;
850  u32_t callSiteNum = 0;
851  u32_t extCallSiteNum = 0;
853  for (const auto &it: *_ae->svfir->getICFG())
854  {
855  if (it.second->getFun())
856  {
857  funs.insert(it.second->getFun());
858  }
859  if (const CallICFGNode *callNode = dyn_cast<CallICFGNode>(it.second))
860  {
861  if (!isExtCall(callNode))
862  {
863  callSiteNum++;
864  }
865  else
866  {
867  extCallSiteNum++;
868  }
869  }
870  }
871  generalNumMap["Func_Num"] = funs.size();
872  generalNumMap["EXT_CallSite_Num"] = extCallSiteNum;
873  generalNumMap["NonEXT_CallSite_Num"] = callSiteNum;
874  timeStatMap["Total_Time(sec)"] = (double)(endTime - startTime) / TIMEINTERVAL;
875 
876 }
unsigned u32_t
Definition: CommandLine.h:18
#define TIMEINTERVAL
Definition: SVFType.h:512
std::string memUsage
std::string getMemUsage()
SVFIR * svfir
protected data members, also used in subclasses
u32_t nodeNum
total num of edge
Definition: GenericGraph.h:703
ICFG * getICFG() const
Definition: SVFIR.h:171
TIMEStatMap timeStatMap
Definition: SVFStat.h:78
double endTime
Definition: SVFStat.h:81
bool isExtCall(const SVFFunction *fun)
Definition: SVFUtil.h:278
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition: GeneralType.h:96

◆ getBlockTrace()

u32_t& SVF::AEStat::getBlockTrace ( )
inline

Definition at line 83 of file AbstractInterpretation.h.

84  {
85  if (generalNumMap.count("Block_Trace") == 0)
86  {
87  generalNumMap["Block_Trace"] = 0;
88  }
89  return generalNumMap["Block_Trace"];
90  }

◆ getFunctionTrace()

u32_t& SVF::AEStat::getFunctionTrace ( )
inline

Definition at line 75 of file AbstractInterpretation.h.

76  {
77  if (generalNumMap.count("Function_Trace") == 0)
78  {
79  generalNumMap["Function_Trace"] = 0;
80  }
81  return generalNumMap["Function_Trace"];
82  }

◆ getICFGNodeTrace()

u32_t& SVF::AEStat::getICFGNodeTrace ( )
inline

Definition at line 91 of file AbstractInterpretation.h.

92  {
93  if (generalNumMap.count("ICFG_Node_Trace") == 0)
94  {
95  generalNumMap["ICFG_Node_Trace"] = 0;
96  }
97  return generalNumMap["ICFG_Node_Trace"];
98  }

◆ getMemUsage()

std::string SVF::AEStat::getMemUsage ( )
inline

Definition at line 59 of file AbstractInterpretation.h.

60  {
61  u32_t vmrss, vmsize;
62  return SVFUtil::getMemoryUsageKB(&vmrss, &vmsize) ? std::to_string(vmsize) + "KB" : "cannot read memory usage";
63  }
bool getMemoryUsageKB(u32_t *vmrss_kb, u32_t *vmsize_kb)
Get memory usage from system file. Return TRUE if succeed.
Definition: SVFUtil.cpp:177

◆ performStat()

void AEStat::performStat ( )
overridevirtual

Implements SVF::SVFStat.

Definition at line 878 of file AbstractInterpretation.cpp.

879 {
880  std::string fullName(_ae->moduleName);
883  if (fullName.find('/') == std::string::npos)
884  {
885  std::string name = fullName;
886  moduleName = name.substr(0, fullName.find('.'));
887  }
888  else
889  {
890  std::string name = fullName.substr(fullName.find('/'), fullName.size());
891  moduleName = name.substr(0, fullName.find('.'));
892  }
893 
894  SVFUtil::outs() << "\n************************\n";
895  SVFUtil::outs() << "################ (program : " << moduleName << ")###############\n";
896  SVFUtil::outs().flags(std::ios::left);
897  unsigned field_width = 30;
898  for (NUMStatMap::iterator it = generalNumMap.begin(), eit = generalNumMap.end(); it != eit; ++it)
899  {
900  // format out put with width 20 space
901  std::cout << std::setw(field_width) << it->first << it->second << "\n";
902  }
903  SVFUtil::outs() << "-------------------------------------------------------\n";
904  for (TIMEStatMap::iterator it = timeStatMap.begin(), eit = timeStatMap.end(); it != eit; ++it)
905  {
906  // format out put with width 20 space
907  SVFUtil::outs() << std::setw(field_width) << it->first << it->second << "\n";
908  }
909  SVFUtil::outs() << "Memory usage: " << memUsage << "\n";
910 
911  SVFUtil::outs() << "#######################################################" << std::endl;
912  SVFUtil::outs().flush();
913 }
const char *const name
Definition: cJSON.h:264
const char *const string
Definition: cJSON.h:172
std::string moduleName
Definition: SVFStat.h:99
std::ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:50

Member Data Documentation

◆ _ae

AbstractInterpretation* SVF::AEStat::_ae

Definition at line 69 of file AbstractInterpretation.h.

◆ count

s32_t SVF::AEStat::count {0}

Definition at line 70 of file AbstractInterpretation.h.

◆ memory_usage

std::string SVF::AEStat::memory_usage

Definition at line 71 of file AbstractInterpretation.h.

◆ memUsage

std::string SVF::AEStat::memUsage

Definition at line 72 of file AbstractInterpretation.h.


The documentation for this class was generated from the following files: