Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

StatCollection.C

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // Last modified on Fri Apr 29 00:13:20 EDT 2005 by ken@xorian.net        
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(/*sizehint=*/ 10), redundant(redundant)
00040 {
00041   // override histogram maps as appropriate
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   // Set the "trouble" end of some statistics to "low".
00059   entryStats[Stat::PcntCommonNames].SetTroubleEnd(StatCount::troubleLow);
00060 }
00061 
00062 StatCount *Stat::Collection::getFanout(int level)
00063 {
00064   // Make sure that the StatCount object for this level exists
00065   while(this->fanout.size() <= level)
00066     this->fanout.addhi(NEW(StatCount));
00067 
00068   // Return the StatCount object for this level
00069   return this->fanout.get(level);
00070 }

Generated on Mon May 8 00:48:36 2006 for Vesta by  doxygen 1.4.2