Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
911fcd2a
Commit
911fcd2a
authored
Dec 11, 2008
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
let profiler trace 'get member' calls, because I suspect they might be slow (linear string lookup)
parent
c6e3cf56
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
0 deletions
+28
-0
src/script/profiler.cpp
src/script/profiler.cpp
+13
-0
src/script/profiler.hpp
src/script/profiler.hpp
+10
-0
src/script/to_value.hpp
src/script/to_value.hpp
+5
-0
No files found.
src/script/profiler.cpp
View file @
911fcd2a
...
...
@@ -104,6 +104,19 @@ Profiler::Profiler(Timer& timer, Variable function_name)
timer
.
exclude_time
();
}
// Enter a function
Profiler
::
Profiler
(
Timer
&
timer
,
const
Char
*
function_name
)
:
timer
(
timer
)
,
parent
(
function
)
// push
{
FunctionProfileP
&
fpp
=
parent
->
children
[(
size_t
)
function_name
];
if
(
!
fpp
)
{
fpp
=
new_intrusive1
<
FunctionProfile
>
(
function_name
);
}
function
=
fpp
.
get
();
timer
.
exclude_time
();
}
// Enter a function
Profiler
::
Profiler
(
Timer
&
timer
,
void
*
function_object
,
const
String
&
function_name
)
:
timer
(
timer
)
...
...
src/script/profiler.hpp
View file @
911fcd2a
...
...
@@ -70,6 +70,8 @@ class FunctionProfile : public IntrusivePtrBase<FunctionProfile> {
String
name
;
ProfileTime
time_ticks
;
UInt
calls
;
/// for each id, called children
/** we (ab)use the fact that all pointers are even to store both pointers and ids */
map
<
size_t
,
FunctionProfileP
>
children
;
/// The children, sorted by time
...
...
@@ -90,8 +92,16 @@ const FunctionProfile& profile_aggregated(int level = 1);
/// Profile a single function call
class
Profiler
{
public:
/// Log the fact that the function function_name is entered, ends when profiler goes out of scope.
/** Time between the construction of Timer and the construction of Profiler is excluded from ALL profiles.
*/
Profiler
(
Timer
&
timer
,
Variable
function_name
);
/// As above, but with a constant name
Profiler
(
Timer
&
timer
,
const
Char
*
function_name
);
/// As above, but using a function object instead of a name,
/** if we haven't seen the object before, it gets the given name. */
Profiler
(
Timer
&
timer
,
void
*
function_object
,
const
String
&
function_name
);
/// Log the fact that the function is left
~
Profiler
();
private:
Timer
&
timer
;
...
...
src/script/to_value.hpp
View file @
911fcd2a
...
...
@@ -11,6 +11,7 @@
#include <script/value.hpp>
#include <script/script.hpp>
#include <script/profiler.hpp>
#include <util/reflect.hpp>
#include <util/error.hpp>
#include <util/io/get_member.hpp>
...
...
@@ -269,6 +270,10 @@ class ScriptObject : public ScriptValue {
ScriptValueP
d
=
getDefault
();
return
d
?
d
->
toImage
(
d
)
:
ScriptValue
::
toImage
(
thisP
);
}
virtual
ScriptValueP
getMember
(
const
String
&
name
)
const
{
#if USE_SCRIPT_PROFILING
Timer
t
;
Profiler
prof
(
t
,
_
(
"get member"
));
#endif
GetMember
gm
(
name
);
gm
.
handle
(
*
value
);
if
(
gm
.
result
())
return
gm
.
result
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment