annotate my_profile.h @ 2832:99d169b25fbf

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