FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
daScript/src/simulate/runtime_profile.cpp at split-heap · Bais/daScript · GitHub
Bais
/
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
/
simulate
/
runtime_profile.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
58 lines (46 loc) · 1.4 KB
Breadcrumbs
daScript
/
src
/
simulate
/
runtime_profile.cpp
Copy path
File metadata and controls
58 lines (46 loc) · 1.4 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
#
include
"
daScript/misc/platform.h
"
#
include
"
daScript/simulate/runtime_range.h
"
#
ifdef
_MSC_VER
#
include
<
windows.h
>
uint64_t
profileGetTime
() {
LARGE_INTEGER
t0;
QueryPerformanceCounter
(&t0);
return
t0.
QuadPart
;
}
double
profileGetTimeSec
(
uint64_t
minT ) {
LARGE_INTEGER
freq;
QueryPerformanceFrequency
(&freq);
return
double
(minT) /
double
(freq.
QuadPart
);
}
#
else
#
include
<
mach/mach.h
>
#
include
<
mach/mach_time.h
>
uint64_t
profileGetTime
() {
return
mach_absolute_time
();
}
double
profileGetTimeSec
(
uint64_t
minT ) {
mach_timebase_info_data_t
s_timebase_info;
mach_timebase_info
(&s_timebase_info);
return
minT * s_timebase_info.
numer
/ (
1000000000.0
* s_timebase_info.
denom
);
}
#
endif
namespace
das
{
float
builtin_profile
(
int32_t
count,
char
* category, Block block, Context * context ) {
count =
max
(count,
1
);
uint64_t
minT = -
1U
;
for
(
int32_t
i =
0
; i != count; ++i ) {
uint64_t
t0 =
profileGetTime
();
context->
invoke
(block,
nullptr
,
nullptr
);
uint64_t
t1 =
profileGetTime
();
minT =
min
(t1-t0, minT);
}
double
tSec =
profileGetTimeSec
(minT);
if
( category ) {
stringstream ss;
ss <<
"
\"
"
<< category <<
"
\"
,
"
<< fixed << tSec <<
"
,
"
<< count <<
"
\n
"
;
context->
to_out
(ss.
str
().
c_str
());
}
return
(
float
) tSec;
}
}
Back
|
FazBrowse Home
|
New Git URL