comparison my_profile.h @ 2834:b7d3b450f8fd

using volatile modifier
author nick
date Sun, 11 Nov 2001 15:20:19 +0000
parents 99d169b25fbf
children e9bd97d5c5cc
comparison
equal deleted inserted replaced
2833:1b6c207c0410 2834:b7d3b450f8fd
3 * 3 *
4 * Copyright (C) Nick Kurshev <nickols_k@mail.ru> - Oct 2001 4 * Copyright (C) Nick Kurshev <nickols_k@mail.ru> - Oct 2001
5 * 5 *
6 * You can redistribute this file under terms and conditions 6 * You can redistribute this file under terms and conditions
7 * of GNU General Public licence v2. 7 * of GNU General Public licence v2.
8 * This file is partly based on vbetest.c from lrmi distributive.
9 */ 8 */
10 #ifndef MY_PROFILE_INC 9 #ifndef MY_PROFILE_INC
11 #define MY_PROFILE_INC 10 #define MY_PROFILE_INC
12 11
13 extern unsigned long long int my_profile_start,my_profile_end,my_profile_total; 12 extern volatile unsigned long long int my_profile_start,my_profile_end,my_profile_total;
14 13
15 #if defined ( ENABLE_PROFILE ) && defined ( ARCH_X86 ) 14 #if defined ( ENABLE_PROFILE ) && defined ( ARCH_X86 )
16 static inline unsigned long long int read_tsc( void ) 15 static inline unsigned long long int read_tsc( void )
17 { 16 {
18 unsigned long long int retval; 17 unsigned long long int retval;
19 __asm __volatile ("rdtsc":"=A"(retval)::"memory"); 18 __asm __volatile ("rdtsc":"=A"(retval)::"memory");
20 return retval; 19 return retval;
21 } 20 }
22 21
23 #define PROFILE_START() (my_profile_start=read_tsc()) 22 #define PROFILE_RESET() (my_profile_total=0ULL)
24 #define PROFILE_END(your_message) { my_profile_end=read_tsc(); my_profile_total+=my_profile_end - my_profile_start; printf(your_message" current=%llu total=%llu\n\t",my_profile_end-my_profile_start,my_profile_total); } 23 #define PROFILE_START() { static int inited=0; if(!inited) { inited=1; my_profile_total=0ULL; } my_profile_start=read_tsc(); }
24 #define PROFILE_END(your_message) { my_profile_end=read_tsc(); my_profile_total+=(my_profile_end-my_profile_start); printf(your_message" current=%llu total=%llu\n\t",(my_profile_end-my_profile_start),my_profile_total); }
25 #else 25 #else
26 #define PROFILE_INIT() 26 #define PROFILE_RESET()
27 #define PROFILE_START() 27 #define PROFILE_START()
28 #define PROFILE_END(your_message) 28 #define PROFILE_END(your_message)
29 #endif 29 #endif
30 30
31 31