SNAP Library 6.0, Developer Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
TStopwatch Class Reference

Routines to benchmark table operations. More...

#include <util.h>

Public Types

enum  TExperiment {
  LoadTables, Preprocess, ConstructGraph, Compute,
  Postprocess, StoreOutputs, AllocateColumnCopies, CopyColumns,
  Sort, Group, MergeNeighborhoods, AddNeighborhoods,
  AddEdges, Sort2, ComputeOffset, ComputeETypes,
  EstimateSizes, InitGraph, ExtractNbrETypes, CopyNodes,
  PopulateGraph, ExtractEdges, BuildSubgraph
}
 List of all experiments. More...
 

Public Member Functions

void Start (const TExperiment Exp)
 Start a new experiment. More...
 
void Stop (const TExperiment Exp)
 Stop the current experiment. More...
 
int Cnt (const TExperiment Exp) const
 Returns the number of experiments. More...
 
double Sum (const TExperiment Exp) const
 Returns the total time of all experiments. More...
 
double Avg (const TExperiment Exp) const
 Returns the average time of all experiments. More...
 
double Max (const TExperiment Exp) const
 Returns the maximum time of all experiments. More...
 
double Min (const TExperiment Exp) const
 Returns the minimum time of all experiments. More...
 

Static Public Member Functions

static TStopwatchGetInstance ()
 

Static Public Attributes

static const int NEXPS = 25
 The expected number of experiments (must be at least equal to the size of the above list) More...
 

Private Member Functions

 TStopwatch ()
 
 TStopwatch (TStopwatch const &)
 
void operator= (TStopwatch const &)
 
double Tick ()
 Routines to benchmark table operations. More...
 

Private Attributes

double Starts [NEXPS]
 
int Cnts [NEXPS]
 
double Sums [NEXPS]
 
double Maxs [NEXPS]
 
double Mins [NEXPS]
 

Detailed Description

Routines to benchmark table operations.

Definition at line 71 of file util.h.

Member Enumeration Documentation

List of all experiments.

Enumerator
LoadTables 
Preprocess 
ConstructGraph 
Compute 
Postprocess 
StoreOutputs 
AllocateColumnCopies 
CopyColumns 
Sort 
Group 
MergeNeighborhoods 
AddNeighborhoods 
AddEdges 
Sort2 
ComputeOffset 
ComputeETypes 
EstimateSizes 
InitGraph 
ExtractNbrETypes 
CopyNodes 
PopulateGraph 
ExtractEdges 
BuildSubgraph 

Definition at line 74 of file util.h.

75  // graph construction
77  // subgraph construction
TExperiment
List of all experiments.
Definition: util.h:74

Constructor & Destructor Documentation

TStopwatch::TStopwatch ( )
inlineprivate

Definition at line 88 of file util.h.

References Mins, and NEXPS.

88  {
89  for (int i = 0; i < NEXPS; i++) { Mins[i] = 100000000000.0; }
90  }; // Constructor? (the {} brackets) are needed here.
static const int NEXPS
The expected number of experiments (must be at least equal to the size of the above list) ...
Definition: util.h:80
double Mins[NEXPS]
Definition: util.h:102
TStopwatch::TStopwatch ( TStopwatch const &  )
private

Member Function Documentation

double TStopwatch::Avg ( const TExperiment  Exp) const

Returns the average time of all experiments.

Definition at line 753 of file util.cpp.

756  {
int TStopwatch::Cnt ( const TExperiment  Exp) const

Returns the number of experiments.

Definition at line 745 of file util.cpp.

static TStopwatch* TStopwatch::GetInstance ( )
inlinestatic

Definition at line 82 of file util.h.

Referenced by TSnap::ToNetworkMP(), and TSnap::ToNetworkMP2().

82  {
83  static TStopwatch instance; // Guaranteed to be destroyed. Instantiated on first use.
84  return &instance;
85  }
Routines to benchmark table operations.
Definition: util.h:71

Here is the caller graph for this function:

double TStopwatch::Max ( const TExperiment  Exp) const

Returns the maximum time of all experiments.

Definition at line 757 of file util.cpp.

761  {
double TStopwatch::Min ( const TExperiment  Exp) const

Returns the minimum time of all experiments.

Definition at line 761 of file util.cpp.

761  {
762  nwritten = (int) write(fd, ptr, nleft);
763  if (nwritten <= 0) {
void TStopwatch::operator= ( TStopwatch const &  )
private
void TStopwatch::Start ( const TExperiment  Exp)

Start a new experiment.

Definition at line 733 of file util.cpp.

Referenced by TSnap::ToNetworkMP(), and TSnap::ToNetworkMP2().

Here is the caller graph for this function:

void TStopwatch::Stop ( const TExperiment  Exp)

Stop the current experiment.

Definition at line 737 of file util.cpp.

Referenced by TSnap::ToNetworkMP(), and TSnap::ToNetworkMP2().

740  {
741  return Sums[Exp] / Cnts[Exp];
742 }
743 
int Cnts[NEXPS]
Definition: util.h:99
double Sums[NEXPS]
Definition: util.h:100

Here is the caller graph for this function:

double TStopwatch::Sum ( const TExperiment  Exp) const

Returns the total time of all experiments.

Definition at line 749 of file util.cpp.

756  {
double TStopwatch::Tick ( )
private

Routines to benchmark table operations.

Definition at line 701 of file util.cpp.

701  {
702  //return clock() / ((double)CLOCKS_PER_SEC);
703 #ifdef USE_OPENMP
704  return omp_get_wtime();
705 #else
706 #ifdef GLib_WIN32
707  return GetTickCount() / 1000.0;
708 #else
709  struct rusage rusage;
710  getrusage(RUSAGE_SELF, &rusage);
711 
712  float cputime =
713  ((float) (rusage.ru_utime.tv_usec + rusage.ru_stime.tv_usec) / 1000000) +
714  ((float) (rusage.ru_utime.tv_sec + rusage.ru_stime.tv_sec));
715  return cputime;
716 #endif
717 #endif
718 }
719 
720 void TStopwatch::Start(const TExperiment Exp) {
721  Starts[Exp] = Tick();
722 }
723 
724 void TStopwatch::Stop(const TExperiment Exp) {
725  double Duration = Tick() - Starts[Exp];
726  Sums[Exp] += Duration;
727  Maxs[Exp] = Maxs[Exp] >= Duration ? Maxs[Exp] : Duration;
728  Mins[Exp] = Mins[Exp] <= Duration ? Mins[Exp] : Duration;
729  Cnts[Exp]++;
730 }
731 
double Tick()
Routines to benchmark table operations.
Definition: util.cpp:701
void Start(const TExperiment Exp)
Start a new experiment.
Definition: util.cpp:733
void Stop(const TExperiment Exp)
Stop the current experiment.
Definition: util.cpp:737
double Starts[NEXPS]
Definition: util.h:98
int Cnts[NEXPS]
Definition: util.h:99
TExperiment
List of all experiments.
Definition: util.h:74
double Sums[NEXPS]
Definition: util.h:100
double Mins[NEXPS]
Definition: util.h:102
double Maxs[NEXPS]
Definition: util.h:101

Member Data Documentation

int TStopwatch::Cnts[NEXPS]
private

Definition at line 99 of file util.h.

double TStopwatch::Maxs[NEXPS]
private

Definition at line 101 of file util.h.

double TStopwatch::Mins[NEXPS]
private

Definition at line 102 of file util.h.

Referenced by TStopwatch().

const int TStopwatch::NEXPS = 25
static

The expected number of experiments (must be at least equal to the size of the above list)

Definition at line 80 of file util.h.

Referenced by TStopwatch().

double TStopwatch::Starts[NEXPS]
private

Definition at line 98 of file util.h.

double TStopwatch::Sums[NEXPS]
private

Definition at line 100 of file util.h.


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