comparison my_profile.h @ 2832:99d169b25fbf

Precised profile stuff
author nick
date Sun, 11 Nov 2001 14:41:19 +0000
parents
children b7d3b450f8fd
comparison
equal deleted inserted replaced
2831:7746bf29000a 2832:99d169b25fbf
1 /*
2 * my_profile.h
3 *
4 * Copyright (C) Nick Kurshev <nickols_k@mail.ru> - Oct 2001
5 *
6 * You can redistribute this file under terms and conditions
7 * of GNU General Public licence v2.
8 * This file is partly based on vbetest.c from lrmi distributive.
9 */
10 #ifndef MY_PROFILE_INC
11 #define MY_PROFILE_INC
12
13 extern unsigned long long int my_profile_start,my_profile_end,my_profile_total;
14
15 #if defined ( ENABLE_PROFILE ) && defined ( ARCH_X86 )
16 static inline unsigned long long int read_tsc( void )
17 {
18 unsigned long long int retval;
19 __asm __volatile ("rdtsc":"=A"(retval)::"memory");
20 return retval;
21 }
22
23 #define PROFILE_START() (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
26 #define PROFILE_INIT()
27 #define PROFILE_START()
28 #define PROFILE_END(your_message)
29 #endif
30
31
32
33 #endif