| 1 |
root |
1.1 |
/* |
| 2 |
|
|
* This file is part of Deliantra, the Roguelike Realtime MMORPG. |
| 3 |
|
|
* |
| 4 |
|
|
* Copyright (©) 2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
| 5 |
|
|
* |
| 6 |
|
|
* Deliantra is free software: you can redistribute it and/or modify |
| 7 |
|
|
* it under the terms of the GNU General Public License as published by |
| 8 |
|
|
* the Free Software Foundation, either version 3 of the License, or |
| 9 |
|
|
* (at your option) any later version. |
| 10 |
|
|
* |
| 11 |
|
|
* This program is distributed in the hope that it will be useful, |
| 12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
|
|
* GNU General Public License for more details. |
| 15 |
|
|
* |
| 16 |
|
|
* You should have received a copy of the GNU General Public License |
| 17 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
|
|
* |
| 19 |
|
|
* The authors can be reached via e-mail to <support@deliantra.net> |
| 20 |
|
|
*/ |
| 21 |
|
|
|
| 22 |
|
|
// This file is only included with -DDEVEL, and is only part |
| 23 |
|
|
// of the distributon for completeness, it is not supposed to |
| 24 |
|
|
// be useful outside the developers machines. |
| 25 |
|
|
|
| 26 |
|
|
#ifndef DEVEL_H |
| 27 |
|
|
#define DEVEL_H |
| 28 |
|
|
|
| 29 |
|
|
// used for benchmarking (x86/amd64-specific) |
| 30 |
|
|
typedef unsigned int cstamp; |
| 31 |
|
|
|
| 32 |
|
|
static inline cstamp |
| 33 |
|
|
stamp (void) |
| 34 |
|
|
{ |
| 35 |
|
|
cstamp tsc; |
| 36 |
root |
1.2 |
asm volatile ("rdtsc" : "=a" (tsc) : : "edx"); |
| 37 |
root |
1.1 |
return tsc; |
| 38 |
|
|
} |
| 39 |
|
|
|
| 40 |
|
|
static inline cstamp |
| 41 |
|
|
measure (cstamp t) |
| 42 |
|
|
{ |
| 43 |
root |
1.2 |
return stamp () - t; |
| 44 |
root |
1.1 |
} |
| 45 |
|
|
|
| 46 |
|
|
// cstamp s = stamp (); |
| 47 |
|
|
// s = measure (s); |
| 48 |
|
|
|
| 49 |
|
|
#endif |
| 50 |
|
|
|