After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 572113 - add profiler
add profiler
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2009-02-17 09:46 UTC by Tommi Komulainen
Modified: 2009-02-17 14:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
add profiler (18.67 KB, patch)
2009-02-17 09:47 UTC, Tommi Komulainen
committed Details | Review

Description Tommi Komulainen 2009-02-17 09:46:34 UTC
Using sysprof and such in javascript heavy application is next to useless as most of the time spent would be attributed to js_Invoke, or js_CallFunction or similar. Would be more useful to get profiling data attributed to javascript functions.
Comment 1 Tommi Komulainen 2009-02-17 09:47:44 UTC
Created attachment 128892 [details] [review]
add profiler

Sending signal USR1 writes current profile statistics to file
${GJS_DEBUG_PROFILER_OUTPUT}.${pid}.${counter++}

Usage:
$ GJS_DEBUG_PROFILER_OUTPUT=/tmp/gjs-profiler gjs-console ...
$ kill -USR1 `pidof gjs-console`
<do something>
$ kill -USR1 `pidof gjs-consle`
$ gnumeric /tmp/gjs-profiler.`pidof gjs-console`.1

The log file contains number of calls made to a function, time spent in
the function and its descendants. Example output (with common filename
prefix removed) :

file:line	function	calls	self	total
modules/jsUnit.js:105	_validateArguments	2	0.01	0.01
testGI.js:1	(unknown)	1	0.00	1.08
modules/jsUnit.js:452	gjstestRun	1	0.01	1.07
(native):0	GIRepositoryNamespace	1	0.00	0.00
modules/jsUnit.js:67	_displayStringForValue	2	0.01	0.01
modules/jsUnit.js:219	setUp	2	0.01	0.01
(native):0	Object	3	0.01	0.01
modules/jsUnit.js:88	argumentsIncludeComments	5	0.01	0.01
modules/jsUnit.js:197	assertRaises	1	0.00	0.18
testGI.js:10	anonymous	1	0.00	0.13
(native):0	(unknown)	2	0.03	0.11
modules/jsUnit.js:222	tearDown	2	0.00	0.00
modules/jsUnit.js:50	jsUnitFixTop	1	0.01	0.01
(native):0	Error	2	0.01	0.01
(native):0	log	2	0.03	0.03
testGI.js:1	testUTF8	1	0.01	0.59
gjs_throw:0	anonymous	2	0.01	0.03
modules/jsUnit.js:111	_assert	2	0.01	0.01
(native):0	GIRepositoryFunction	2	0.01	0.01
modules/jsUnit.js:146	assertEquals	1	0.00	0.11
modules/jsUnit.js:99	nonCommentArg	3	0.02	0.03
modules/jsUnit.js:92	commentArg	2	0.01	0.02
modules/jsUnit.js:1	(unknown)	1	0.01	0.07
(native):0	GIRepository	1	0.00	0.00
testGI.js:7	testThrows	1	0.01	0.20
Comment 2 Johan Bilien 2009-02-17 10:25:49 UTC
Looks very nice to me
Comment 3 Tommi Komulainen 2009-02-17 14:39:18 UTC
Committed as 2cf2181ed25133d7376678a97765235d70b870f0