Violin Instrumenting JavaScript

This is an experiment in instrumenting JavaScript applications.

On the right is the Object and Function graph for a simple Backbone app ( the code).

The app's code has been instrumented to draw and animate the graph as the JavaScript runs without having to modify the app's original code at all (by hand anyway).

Hit the button to start the backbone app and interact with it.

Metaprogramming rocks :).

This is an experiment by Philip Roberts. You can follow me on twitter @philip_roberts.

If you have any thoughts please leave me a comment.

The App Code


This is a first attempt at instrumenting a JavaScript application.

Instrumenting is performed by recursively iterating over the application's namespace to build the graph, and decorating any functions to trigger events when they are called.

Currently the graph shows the Object heirarchy, rather than the prototype hierarchy or all the instantiations of the object, and function nodes on the graph will be triggered when any instantiation of that object calls the function.

The code


comments powered by Disqus