basix_doc 0.1
/Users/mourrain/Devel/mmx/basix/include/basix/timer.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : timer.hpp
00004 * DESCRIPTION: Time related routines
00005 * COPYRIGHT  : (C) 2003  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license and comes WITHOUT
00008 * ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
00009 * If you don't have this file, write to the Free Software Foundation, Inc.,
00010 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00011 ******************************************************************************/
00012 
00013 #ifndef __MMX_TIMER_HPP
00014 #define __MMX_TIMER_HPP
00015 #include <basix/string.hpp>
00016 #if BASIX_HAVE_STDINT_H
00017 #include<stdint.h>
00018 #endif
00019 
00021 
00022 namespace mmx {
00023 
00025 nat mmx_time ();
00026 double mmx_var_time ();
00027 inline string mmx_time_unit () { return("ms"); };
00028 
00030 nat mmx_user_time();
00031 inline string mmx_user_time_unit () { return("ms"); };
00032 
00034 #if (defined(__GNUC__) && defined(__i386__) && BASIX_HAVE_STDINT_H)
00035 extern __inline__ nat mmx_cpu_time () {
00036   uint64_t x;
00037   __asm__ volatile ("rdtsc" : "=A" (x));
00038   return (nat) x;
00039 }
00040 #elif (defined(__GNUC__) && defined(__amd64__) && BASIX_HAVE_STDINT_H)
00041 extern __inline__ nat mmx_cpu_time () {
00042   uint64_t a, d;
00043   __asm__ volatile ("rdtsc" : "=a" (a), "=d" (d));
00044   return (nat) ((d<<32) | a);
00045 }
00046 #else
00047 #include <time.h>
00048 inline nat mmx_cpu_time () {
00049   return (nat) clock ();
00050 }
00051 #endif
00052 inline string mmx_cpu_time_unit () { return("tk"); };
00053 
00054 } // namespace mmx
00055 #endif // __MMX_TIMER_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines