profile.h
Go to the documentation of this file.00001 #ifndef _GPXE_PROFILE_H
00002 #define _GPXE_PROFILE_H
00003
00004
00005
00006
00007
00008
00009
00010 FILE_LICENCE ( GPL2_OR_LATER );
00011
00012 #include <stdint.h>
00013
00014
00015
00016
00017 union profiler {
00018
00019 uint64_t timestamp;
00020
00021
00022
00023
00024 struct {
00025 uint32_t eax;
00026 uint32_t edx;
00027 } rdtsc;
00028 };
00029
00030
00031
00032
00033 static union profiler simple_profiler;
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 static inline __attribute__ (( always_inline )) unsigned long
00053 profile ( union profiler *profiler ) {
00054 uint64_t last_timestamp = profiler->timestamp;
00055
00056 __asm__ __volatile__ ( "rdtsc" :
00057 "=a" ( profiler->rdtsc.eax ),
00058 "=d" ( profiler->rdtsc.edx ) );
00059 return ( profiler->timestamp - last_timestamp );
00060 }
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 static inline __attribute__ (( always_inline )) unsigned long
00076 simple_profile ( void ) {
00077 return profile ( &simple_profiler );
00078 }
00079
00080 #endif