00001 /* 00002 * This file: libastrog_timer.h is part of the Astrog software library 00003 * that uses the graphics processing unit (GPU) to accelerate 00004 * astronomy calculations. 00005 * 00006 * Copyright (C) 2007 C. J. Harris, B. J. Mort 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00021 * 02110-1301 USA 00022 */ 00023 00028 #include "libastrog_astrog.h" 00029 #include <sys/timeb.h> 00030 00031 namespace astrog { 00032 00060 class Timer { 00061 00062 public: 00066 Timer(); 00067 00071 ~Timer(); 00072 00079 void start(); 00086 void stop(); 00088 void reset(); 00090 double get_time(); 00092 double get_error_absolute(); 00094 double get_error_relative(); 00096 double get_error_percentage(); 00098 static double get_grain(); 00099 00100 private: 00102 static void set_grain(); 00104 static double grain; 00111 int timer_status; 00119 double time_elapsed; 00128 int error_grains; 00132 struct timeb latest_start; 00136 struct timeb latest_stop; 00137 00138 00139 }; 00140 00141 } // end namespace