-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Factor the stats out into a separate file, display some better stats
- Loading branch information
Timo Ewalds
committed
Feb 28, 2010
1 parent
9c6bd75
commit 0aa0c76
Showing
3 changed files
with
54 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
#ifndef _DEPTHSTATS_H_ | ||
#define _DEPTHSTATS_H_ | ||
|
||
#include <stdint.h> | ||
#include <cmath> | ||
#include <string> | ||
#include "string.h" | ||
using namespace std; | ||
|
||
struct DepthStats { | ||
uint32_t mindepth, maxdepth, num; | ||
uint64_t sumdepth, sumdepthsq; | ||
|
||
DepthStats(){ | ||
num = 0; | ||
mindepth = 1000000000; | ||
maxdepth = 0; | ||
sumdepth = 0; | ||
sumdepthsq = 0; | ||
} | ||
void add(int depth){ | ||
num++; | ||
if(mindepth > depth) mindepth = depth; | ||
if(maxdepth < depth) maxdepth = depth; | ||
sumdepth += depth; | ||
sumdepthsq += depth*depth; | ||
} | ||
|
||
int avg(){ | ||
return sumdepth/num; | ||
} | ||
double std_dev(){ | ||
return sqrt((double)sumdepthsq/num - ((double)sumdepth/num)*((double)sumdepth/num)); | ||
} | ||
string to_s(){ | ||
return "avg=" + to_str(avg()) +", std-dev=" + to_str(std_dev()) + ", min=" + to_str(mindepth) + ", max=" + to_str(maxdepth) + ", num=" + to_str(num); | ||
} | ||
}; | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters