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

stats.h

Go to the documentation of this file.
00001 // -*- mode: C++; c-file-style: "stroustrup"; c-basic-offset: 4; indent-tabs-mode: nil; -*-
00002 ////////////////////////////////////////////////////////////////////
00003 //
00004 // Filename : stats.h
00005 //
00006 // General statistics meant for experiments but not in the release
00007 // version of UPPAAL.
00008 //
00009 // This file is a part of the UPPAAL toolkit.
00010 // Copyright (c) 1995 - 2003, Uppsala University and Aalborg University.
00011 // All right reserved.
00012 //
00013 // $Id: $
00014 //
00015 ///////////////////////////////////////////////////////////////////
00016 
00017 #ifndef INCLUDE_BASE_STATS_H
00018 #define INCLUDE_BASE_STATS_H
00019 
00020 #ifdef SHOW_STATS
00021 
00022 #include "hash/tables.h"
00023 
00024 namespace base
00025 {
00026     class Stats
00027     {
00028     public:
00029         Stats() {}
00030         ~Stats();
00031 
00032         void count(const char *statName, const char *subStat = NULL);
00033 
00034         struct stat_t
00035         {
00036             stat_t(const char *statName, stat_t *nxt)
00037                 : name(statName), counter(1), next(nxt) {}
00038             ~stat_t() { delete next; }
00039 
00040             const char *name;
00041             long counter;
00042             stat_t *next;
00043         };
00044 
00045         struct entry_t : public hash::TableSingle<entry_t>::Bucket_t
00046         {
00047             entry_t(const char *name, stat_t *next = NULL)
00048                 : stat(name, next) {}
00049 
00050             stat_t stat; // Main stat, with list of sub-stats.
00051         };
00052 
00053     private:
00054         hash::TableSingle<entry_t> table;
00055     };
00056 
00057     extern Stats stats;
00058 }
00059 
00060 // Typical way of using stats:
00061 
00062 #define RECORD_STAT()        base::stats.count(__PRETTY_FUNCTION__, NULL)
00063 #define RECORD_SUBSTAT(NAME) base::stats.count(__PRETTY_FUNCTION__, NAME)
00064 #define RECORD_NSTAT(ROOT, NAME)\
00065 base::stats.count(ROOT, NULL);  \
00066 base::stats.count(ROOT, NAME)
00067 
00068 #else
00069 
00070 #define RECORD_STAT()
00071 #define RECORD_SUBSTAT(NAME)
00072 #define RECORD_NSTAT(ROOT, NAME)
00073 
00074 #endif // SHOW_STATS
00075 
00076 #endif // INCLUDE_BASE_STATS_H

Generated on Fri Jun 30 00:02:30 2006 for Module base by  doxygen 1.4.2