Profiling with PhantomJS

795 views
Skip to first unread message

Dav Glass

unread,
Nov 1, 2012, 10:03:58 AM11/1/12
to phan...@googlegroups.com
I've been thinking of ways to help developers with simple profiling of their tests/pages with Phantom.

I'm not familiar with the code base, but here's what I'm thinking..

Patch the console.profileEnd(); to return a JSON object of the profiler data that we can programatically access from JS. Then the person wrapping/using Phantom can report the results. Print them, log them, etc..

Thoughts?

Ivan De Marino

unread,
Nov 1, 2012, 10:11:47 AM11/1/12
to phan...@googlegroups.com
Sounds intereting.

Let's see some code ;)

--
You received this message because you are subscribed to the Google Groups "phantomjs" group.
Visit this group at http://groups.google.com/group/phantomjs?hl=en.
 
 



--
Ivan De Marino
Coder, Technologist, Cook, Italian

blog.ivandemarino.me | www.linkedin.com/in/ivandemarino | twitter.com/detronizator

Ariya Hidayat

unread,
Nov 3, 2012, 11:02:59 AM11/3/12
to phan...@googlegroups.com
To help me imagining this case, can you try to write an exemplary
script of that profiling assuming the functionality is already
implemented?

Something slightly related:
http://code.google.com/p/phantomjs/issues/detail?id=386 (Make Web
Inspector back-end functionalities available at run-time).



--
Ariya Hidayat, http://ariya.ofilabs.com
http://twitter.com/ariyahidayat

James Greene

unread,
Nov 4, 2012, 2:22:08 PM11/4/12
to phan...@googlegroups.com
I would also like to see a quick usage example.
~~James

Owen Davis

unread,
Nov 4, 2012, 7:42:20 PM11/4/12
to phan...@googlegroups.com
One of my co-workers wrote a tool to capture a lot of performance data (like google page speed or yslow does) using phantom.   It should give you a pretty good idea of what metrics you can collect without having to patch anything, and it optionally emits json and csv.

Dav Glass

unread,
Nov 5, 2012, 9:26:45 AM11/5/12
to phan...@googlegroups.com
Basically, I want to be able to do this inside of a test file:

console.profile('foo');
//Some code
console.profileEnd('foo');

Then when run through Phantom be able to access the data from that
profile (in JSON) and write it out to disk so I can store and compare
it later.

As far as I can tell, that data is not exportable in a programatic
way, it's always sent to the Web Inspector panel to display the tree.

Dav


--
Dav Glass
davg...@gmail.com
blog.davglass.com


+ Windows: n. - The most successful computer virus, ever. +
+ A computer without a Microsoft operating system is like a dog
without bricks tied to its head +
+ A Microsoft Certified Systems Engineer is to computing what a
McDonalds Certified Food Specialist is to fine cuisine +

James Greene

unread,
Nov 5, 2012, 10:22:28 AM11/5/12
to phan...@googlegroups.com
Cool, that sounds good and practical to me.

Note: In addition to the issue that Ariya already mentioned (#386), I'd say this is also somewhat related to http://code.google.com/p/phantomjs/issues/detail?id=232 (Support more console methods)

The latter relation concerns me as I've always been surprised that these console methods aren't already available via WebKit/QtWebKit.  Ariya, any idea how to get them there?  I would've assumed it was just some build config item that needs to be added but perhaps it's deeper than that.

~~James
Reply all
Reply to author
Forward
0 new messages