FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
daScript/src/hal/performance_time.cpp at master · throwthisaway/daScript · GitHub
throwthisaway
/
daScript
Public
forked from
GaijinEntertainment/daScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
daScript
/
src
/
hal
/
performance_time.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
84 lines (63 loc) · 1.88 KB
Breadcrumbs
daScript
/
src
/
hal
/
performance_time.cpp
Copy path
File metadata and controls
84 lines (63 loc) · 1.88 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#
include
"
daScript/misc/platform.h
"
#
include
"
daScript/misc/performance_time.h
"
#
if
DAS_PROFILE_SECTIONS
namespace
das
{
ProfileSection::ProfileSection
(
const
char
* n) {
name = n;
timeStamp =
ref_time_ticks
();
}
ProfileSection::~ProfileSection
() {
int
usec =
get_time_usec
(timeStamp);
printf
(
"
\"
%s
\"
, %.4f
\n
"
, name ? name :
"
unspecified
"
, usec /
1000000
.
0f
);
}
}
#
endif
#
ifdef
_MSC_VER
#
define
WIN32_LEAN_AND_MEAN
#
include
<
windows.h
>
extern
"
C
"
int64_t
ref_time_ticks
() {
LARGE_INTEGER
t0;
QueryPerformanceCounter
(&t0);
return
t0.
QuadPart
;
}
extern
"
C
"
int
get_time_usec
(
int64_t
reft ) {
int64_t
t0 =
ref_time_ticks
();
LARGE_INTEGER
freq;
QueryPerformanceFrequency
(&freq);
return
int
((t0-reft)*
1000000LL
/freq.
QuadPart
);
}
extern
"
C
"
int64_t
get_time_nsec
(
int64_t
reft ) {
int64_t
t0 =
ref_time_ticks
();
LARGE_INTEGER
freq;
QueryPerformanceFrequency
(&freq);
return
int64_t
((t0-reft)*
1000000000LL
/freq.
QuadPart
);
}
#
elif
__linux__ || defined(_EMSCRIPTEN_VER)
#
include
<
time.h
>
const
uint64_t
NSEC_IN_SEC
=
1000000000LL
;
extern
"
C
"
int64_t
ref_time_ticks
() {
timespec ts;
if
(
clock_gettime
(
CLOCK_MONOTONIC
, &ts) !=
0
) {
DAS_ASSERT
(
false
);
return
-
1
;
}
return
ts.
tv_sec
*
NSEC_IN_SEC
+ ts.
tv_nsec
;
}
extern
"
C
"
int
get_time_usec
(
int64_t
reft ) {
return
int
((
ref_time_ticks
() - reft) / (
NSEC_IN_SEC
/
1000000LL
));
}
extern
"
C
"
int64_t
get_time_nsec
(
int64_t
reft ) {
return
ref_time_ticks
() - reft;
}
#
else
//
osx
#
include
<
time.h
>
extern
"
C
"
int64_t
ref_time_ticks
() {
return
clock_gettime_nsec_np
(
CLOCK_MONOTONIC_RAW
);
}
extern
"
C
"
int
get_time_usec
(
int64_t
reft ) {
return
(
clock_gettime_nsec_np
(
CLOCK_MONOTONIC_RAW
) - reft)/
1000LL
;
}
extern
"
C
"
int64_t
get_time_nsec
(
int64_t
reft ) {
return
clock_gettime_nsec_np
(
CLOCK_MONOTONIC_RAW
) - reft;
}
#
endif
Back
|
FazBrowse Home
|
New Git URL