bench.h

Go to the documentation of this file.
00001 /* Gnome gxsm - Gnome X Scanning Microscopy
00002  * universal STM/AFM/SARLS/SPALEED/... controlling and
00003  * data analysis software
00004  * 
00005  * Copyright (C) 1999 The Free Software Foundation
00006  *
00007  * Authors: Percy Zahl <zahl@fkp.uni-hannover.de>
00008  * additional features: Andreas Klust <klust@fkp.uni-hannover.de>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00023  */
00024 
00025 /*@
00026  *@     File:   bench.h
00027  *@     $Header: /cvsroot/gxsm/Gxsm-2.0/src/bench.h,v 1.3 2003/07/29 20:01:03 zahl Exp $
00028  *@     Datum:  17.2.1999
00029  *@     Author: P.Zahl  e-mail: zahl@dynamic.fkp.uni-hannover.de
00030  *@     Zweck:  for Benchmarks
00031  *@             Objekt stoppt die Zeit zwischen Konstruktor / start und stop
00032  *@             Ausgabe incl. Info. und Normierung auf NumOps über << operator
00033  *@
00034  *@     Funktionen:
00035  *@             
00036  *@             
00037  *@             
00038  *@     History:
00039  *@     =====================================================================
00040  *@     V1.00 Basisversion
00041  *@@    08.11.97 PZ: neu !
00042  *@@
00043  */
00044 
00045 #ifndef __BENCH_H_
00046 #define __BENCH_H_
00047 
00048 #ifdef XSM_MATH_BENCHMARK
00049 #include <iostream>
00050 #include <time.h>
00051 #include <string.h>
00052 
00053 class bench{
00054  public:
00055   bench(const char *I=NULL, unsigned long N=1L){
00056     dt=0.; NumOps=N; 
00057     strcpy(Info, "XSM Benchmark: "); if(I) strcat(Info, I);
00058     t0 = clock();
00059   }
00060   void start(){ dt=0.; t0 = clock(); };
00061   void stop(){ t1 = clock(); dt = (double)(t1-t0)/CLOCKS_PER_SEC; }
00062   double getdt(){ return dt; };
00063   friend ostream &operator <<(ostream &o, bench &bench){
00064     return o << bench.Info << std::endl
00065              << "Exec Time: " << bench.dt << "s" << std::endl
00066              << "PixOp/s  : " << (double)((double)bench.NumOps/bench.dt) << "/s" << std::endl;
00067   };
00068  private:
00069   clock_t t0;
00070   clock_t t1;
00071   double dt;
00072   char Info[256];
00073   unsigned long NumOps;
00074 };
00075 
00076 #define BenchStart(B,I,N) bench B(I,N)
00077 #define BenchStop(B)      B.stop(); XSM_DEBUG (DBG_L2 << B)
00078 
00079 #else /* Dummy */
00080 #define BenchStart(B,I,N)
00081 #define BenchStop(B)
00082 #endif
00083 
00084 #endif /* __BENCH_H */

Generated on Sat Apr 1 09:03:52 2006 for GXSM by  doxygen 1.4.6