00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "StatCollection.H"
00022
00023 static char *Log2Name = "ceiling(log_2(x))";
00024 static int Log2(int x) throw ()
00025 {
00026 int res = 0;
00027 for (unsigned int n = 1U; n < x; n <<= 1) res++;
00028 return res;
00029 }
00030
00031 static char *Div2Name = "ceiling(x/2)";
00032 static char *Div5Name = "ceiling(x/5)";
00033 static char *Div10Name = "ceiling(x/10)";
00034 static int Div2(int x) throw () { return (x+1) >> 1; }
00035 static int Div5(int x) throw () { return (x+4) / 5; }
00036 static int Div10(int x) throw () { return (x+9) / 10; }
00037
00038 Stat::Collection::Collection(bool redundant)
00039 : fanout( 10), redundant(redundant)
00040 {
00041
00042 entryStats[Stat::MPKFileSize].SetHistoMap(Log2Name, Log2);
00043 entryStats[Stat::PKFileSize].SetHistoMap(Log2Name, Log2);
00044 entryStats[Stat::NumNames].SetHistoMap(Div10Name, Div10);
00045 entryStats[Stat::NameSize].SetHistoMap(Div2Name, Div2);
00046 entryStats[Stat::NumCommonNames].SetHistoMap(Div10Name, Div10);
00047 entryStats[Stat::PcntCommonNames].SetHistoMap(Div5Name, Div5);
00048 entryStats[Stat::NumEntryNames].SetHistoMap(Div10Name, Div10);
00049 entryStats[Stat::NumUncommonNames].SetHistoMap(Div10Name, Div10);
00050 entryStats[Stat::PcntUncommonNames].SetHistoMap(Div5Name, Div5);
00051 entryStats[Stat::ValueSize].SetHistoMap(Log2Name, Log2);
00052 entryStats[Stat::NumDIs].SetHistoMap(Div5Name, Div5);
00053 entryStats[Stat::NameMapSize].SetHistoMap(Div10Name, Div10);
00054 entryStats[Stat::ValPfxTblSize].SetHistoMap(Div10Name, Div10);
00055 entryStats[Stat::NumRedundantNames].SetHistoMap(Div10Name, Div10);
00056 entryStats[Stat::PcntRedundantNames].SetHistoMap(Div5Name, Div5);
00057
00058
00059 entryStats[Stat::PcntCommonNames].SetTroubleEnd(StatCount::troubleLow);
00060 }
00061
00062 StatCount *Stat::Collection::getFanout(int level)
00063 {
00064
00065 while(this->fanout.size() <= level)
00066 this->fanout.addhi(NEW(StatCount));
00067
00068
00069 return this->fanout.get(level);
00070 }