diff options
author | Erik Verbruggen <erik.verbruggen@me.com> | 2013-08-29 19:42:50 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-12 16:54:03 +0200 |
commit | c679be408a61c2bc4d5484d36d4a2e8e94bd480e (patch) | |
tree | b4ae1f635f8b8b2fc431e5bca73d45662c627a5a /src/qml/jsruntime/qv4runtime_p.h | |
parent | 39a92ca0d473b845247f801a546de84baff15bfe (diff) |
V4: add counters for built-in function invocations.
When enabled, counters for the number of invocations of built-in runtime
functions are dumped when the application exits normally.
Note: this gives a penalty on execution speed. It is not meant to be
super light-weight, but as a tool to have an indication which functions
get called most, thereby helping to indicate which code-paths to
optimize.
Change-Id: Ica701f36a578affcce5ee8414532259972e5ede5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4runtime_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4runtime_p.h | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index d1ca86fddd..14d123e512 100644 --- a/src/qml/jsruntime/qv4runtime_p.h +++ b/src/qml/jsruntime/qv4runtime_p.h @@ -57,18 +57,36 @@ //#include <wtf/MathExtras.h> -#ifdef DO_TRACE_INSTR -# define TRACE1(x) fprintf(stderr, " %s\n", __FUNCTION__); -# define TRACE2(x, y) fprintf(stderr, " %s\n", __FUNCTION__); -#else -# define TRACE1(x) -# define TRACE2(x, y) -#endif // TRACE1 - QT_BEGIN_NAMESPACE +#undef QV4_COUNT_RUNTIME_FUNCTIONS + namespace QV4 { +#ifdef QV4_COUNT_RUNTIME_FUNCTIONS +class RuntimeCounters +{ +public: + RuntimeCounters(); + ~RuntimeCounters(); + + static RuntimeCounters *instance; + + void count(const char *func, uint tag); + void count(const char *func, uint tag1, uint tag2); + +private: + struct Data; + Data *d; +}; + +# define TRACE1(x) RuntimeCounters::instance->count(Q_FUNC_INFO, x.type()); +# define TRACE2(x, y) RuntimeCounters::instance->count(Q_FUNC_INFO, x.type(), y.type()); +#else +# define TRACE1(x) +# define TRACE2(x, y) +#endif // QV4_COUNT_RUNTIME_FUNCTIONS + enum TypeHint { PREFERREDTYPE_HINT, NUMBER_HINT, |