console.io icon indicating copy to clipboard operation
console.io copied to clipboard

Profiling Support

Open nkashyap opened this issue 11 years ago • 3 comments

From: Igor Bezkrovny

Hi,

We are working on SmartTV HTML5 games on wide range of TV platforms.

Profiling such games on device is only way to make games running fast. Profiling is must-have for development on SmartTV devices for us.

There are 2 methods to implement profiler in JS I see:

  1. Project, that has been written in 8 hours in total: https://github.com/igor-bezkrovny/jsprofiler

I was inspired by deprecated yahoo profiler, but yui profiler very limited. So I used idea(such idea is used in john resig inheritance and stacktrace.js and so on) and implemented very useful profiler for SmartTV (JS). Please do not be angry on widget code - it is constantly under small improvements of information output.

Method: Walk recursively and instrument every found function and it's prototype. Minuses: a) anonymous function can't be instrumented automatically b) you should tell profiler which object/objects should be walked by profiler before html5 application start To instrument all global methods/classes/objects just use 'window' as root object

If you will be interested I have much more fresh and updated version (not published it yet).

  1. Method: take AST(with Esprima for example), walk recursively, add call to small instrumentation utility methods before and after all functions and even to getters/setters and read-only properties, after that remove all original code in runtime, convert AST back to JS string (Esprima supports that) and eval all that code. We have all methods instrumented. Minuses: too complex implementation, possible unknown number of restrictions for eval'ing code on real projects, and memory consuming during instrumentation/ast generation/...

Also there is another model of profiling code, as it is done in chrome/firefox profilers. Difference between https://github.com/igor-bezkrovny/jsprofiler and chrome/firefox is that jsprofiler constantly updates and allows to profile dynamic problems in js games, it allows to see changes during game play without need to manual compare of snapshots of chrome's profilers every second.

It is very good idea to add profiler to console.io. What do you think?

nkashyap avatar Aug 30 '13 08:08 nkashyap

  • SHA: 2b474e04390a0623b8beb4849ef8876e811003e0
  • SHA: ae882480ac84357b955d67d9a364af643d84e34f
  • SHA: 644cbd178d6f8ac129d7c4483385dad2428ad820
  • SHA: a87372237d4ef9da7d2c341c69ddb0856a1d0bf1
  • SHA: fdbe4f8d921e7efd058e379fbb3e08a220571aed
  • SHA: 69f55b40d993fae3c47b73edf28c9c86d864f19a
  • SHA: fcc74a7008c937e9681b453a5fd0f0720028f47f
  • SHA: b1060ce9b27911532b0c8b5f7bf3de78a0d9a733
  • SHA: 7031adada22740208976722e4c977e6edb1a2228
  • SHA: ef28cd8139ddae6326d4c530eab8ca1ce397a101

nkashyap avatar Oct 01 '13 11:10 nkashyap

  • SHA: dabf8998282129e114f675cd61a9caf8925fcd0d
  • SHA: 3baace9589a21b6274e416f93287b304dc09f18c
  • SHA: 801ab02cefd29c57e540c38d1da2a6302247719c
  • SHA: 872b3e534a6580e38c11ff4f13c1639f59735c02
  • SHA: 9057c06a9e402613e5de1d73a596e041b6bbeac7
  • SHA: 586c785b1bae4de651800fb7a51742171bb3df0f
  • SHA: 52d6bd32ba8e5cf31e35f8e484f0035769a0bb22
  • SHA: 3763cc16f1f684b71b52e3bf7d5117af69fa6a47
  • SHA: ca131059cfc922b25bc213dee14eb9689ea7ada0
  • SHA: 6a91f8dde2eed199b0040df6d24e0bd29f3539ff

nkashyap avatar Oct 01 '13 11:10 nkashyap

  • SHA: 18007a9d7beb1838ea90474fc9a8228c45f65a01
  • SHA: a640cee56c354078012d266ffbdd33a6c8e07f62

nkashyap avatar Oct 01 '13 11:10 nkashyap