GithubHelp home page GithubHelp logo

call-trace's Introduction

call-trace.js

Instruments a JavaScript file to record its call graph and (optionally) time spent in each function. When the file is run in the browser, a trace can be converted to the Chrome CPU profile format for viewing in DevTools.

Super buggy and doesn't work for most fairly normal code. Don't actually use this :)

Usage:

./call-trace.js input.js --time > output.js

When the output is loaded and then run, a global variable _$wɔk is created containing a trace through the code you just ran.

A CPU profile can be generated from the trace:

copy(JSON.stringify(_$wɔk.getReport()))

Then save your clipboard contents and load in Chrome DevTools.

image

Exploring the data

The global variable _$wɔk also has the following properties:

  • file: the full path of the original source file.
  • fns: a list of all functions found in the file.
  • t: a record of the call graph. Positive values represent entering a function (with the value indicating a function in f) and negative values represent exiting a function (with the absolute value indexing f).
  • d: a record of timestamps for every entry in t. Only created if the --time option was specified.

call-trace's People

Contributors

brendankenny avatar paulirish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

call-trace's Issues

automating

need to add support for running on node and not having to copy(JSON.stringify(...)) like an idiot

You could use https://github.com/cyrus-and/chrome-remote-interface to evaluate that command. So probably something like...

# instrument a file
call-trace --instrument file.js > file.instrumented.js

# user runs it in a browser that's got debug port 9222 open (first tab ;)

# pull the results
call-trace --pull > output.cpuprofile

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.