GEOS: profiler.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# profiler.h

    00001 /**********************************************************************
    00002  * $Id: profiler.h,v 1.4 2004/12/03 16:21:07 frank Exp $
    00003  *
    00004  * GEOS - Geometry Engine Open Source
    00005  * http://geos.refractions.net
    00006  *
    00007  * Copyright (C) 2001-2002 Vivid Solutions Inc.
    00008  *
    00009  * This is free software; you can redistribute and/or modify it under
    00010  * the terms of the GNU Lesser General Public Licence as published
    00011  * by the Free Software Foundation.
    00012  * See the COPYING file for more information.
    00013  *
    00014  **********************************************************************/
    00015
    00016 #ifndef GEOS_PROFILER_H
    00017 #define GEOS_PROFILER_H
    00018
    00019 #include <memory>
    00020 #include <vector>
    00021 #include <map>
    00022 #include <iostream>
    00023 #include <string>
    00024 #ifndef _MSC_VER
    00025 #  include <sys/time.h>
    00026 #endif
    00027 #include <geos/timeval.h>
    00028
    00029 #ifndef PROFILE
    00030 #define PROFILE 0
    00031 #endif
    00032
    00033 using namespace std;
    00034
    00035 namespace geos {
    00036
    00037
    00038 /*
    00039  * \class Profile utils.h geos.h
    00040  *
    00041  * \brief Profile statistics
    00042  */
    00043 class Profile {
    00044 public:
    00046         Profile(string name);
    00047
    00049         ~Profile();
    00050
    00052         void start();
    00053
    00055         void stop();
    00056
    00058         double getMax() const;
    00059
    00061         double getMin() const;
    00062
    00064         double getTot() const;
    00065
    00067         double getAvg() const;
    00068
    00070         unsigned int getNumTimings() const;
    00071
    00073         string name;
    00074
    00075
    00076 private:
    00077
    00078         /* \brief current start and stop times */
    00079         struct timeval starttime, stoptime;
    00080
    00081         /* \brief actual times */
    00082         vector<double> timings;
    00083
    00084         /* \brief total time */
    00085         double totaltime;
    00086
    00087         /* \brief max time */
    00088         double max;
    00089
    00090         /* \brief max time */
    00091         double min;
    00092
    00093         /* \brief max time */
    00094         double avg;
    00095
    00096 };
    00097
    00098 /*
    00099  * \class Profiler utils.h geos.h
    00100  *
    00101  * \brief Profiling class
    00102  *
    00103  */
    00104 class Profiler {
    00105
    00106 public:
    00107
    00108         Profiler();
    00109         ~Profiler();
    00110
    00116         static Profiler *instance(void);
    00117
    00123         void start(string name);
    00124
    00130         void stop(string name);
    00131
    00133         Profile *get(string name);
    00134
    00135         map<string, Profile *> profs;
    00136 };
    00137
    00138
    00140 ostream& operator<< (ostream& os, const Profile&);
    00141
    00143 ostream& operator<< (ostream& os, const Profiler&);
    00144
    00145 }
    00146 #endif // ndef GEOS_PROFILER_H
    00147
    00148 /**********************************************************************
    00149  * $Log: profiler.h,v $
    00150  * Revision 1.4  2004/12/03 16:21:07  frank
    00151  * dont try for sys/time.h with MSVC
    00152  *
    00153  * Revision 1.3  2004/11/30 16:44:16  strk
    00154  * Added gettimeofday implementation for win32, curtesy of Wu Yongwei.
    00155  *
    00156  * Revision 1.2  2004/11/04 08:49:13  strk
    00157  * Unlinked new documentation.
    00158  *
    00159  * Revision 1.1  2004/11/01 16:43:04  strk
    00160  * Added Profiler code.
    00161  * Temporarly patched a bug in DoubleBits (must check drawbacks).
    00162  * Various cleanups and speedups.
    00163  *
    00164  **********************************************************************/