### Function Instrumentation traces and reveals what is being called

    Array.prototype.swap = function (i, j) {
        var k = this[i]; this[i] = this[j]; this[j] = k;
    }

    function bubbleSort(list) {
        var items = list.slice(0), swapped = false, p, q;
        for (p = 1; p < items.length; ++p) {
            for (q = 0; q < items.length - p; ++q) {
                if (items[q + 1] < items[q]) {
                    items.swap(q, q + 1);
                    swapped =true;
                }
            }
            if (!swapped) break;
        }
        return items;
    }

    var N = 100, data = []; while (N > 0) data.push(N--);
    bubbleSort(data);

Ready.

Pressing Run button will execute (using `eval`) the code with some extra instrumentation injected to track the execution. Placing the mouse cursor on the indicator next to every function will show the number of calls for that particular function.

Warning: Never run untrusted code!

Esprima is created and mantained by Ariya Hidayat.

- @Esprima
- GitHub