How do I turn on V8 flags such as --log-timer-events?


I am trying to profile the startup performance using one of V8 flags, --log-timer-events. I was wondering how I can enable it for atom. I added the flag to app.commandLine.appendSwitch in so that every window (renderer process) creates a log file. However, I am not sure how I can profile the main process. If the entry point for the main process is available as a JavaScript file, I think I can pass -js-flags to electron, but atom’s core is written in coffeescript and compiled and put into asar.

This leads to more general questions regarding the dev workflow:

  1. Which file is the entry point to the main process?
  2. Is it possible to have compiled JavaScript files and start atom from them?
  3. If not, how can I set --log-timer-events for the main process?



Which file is the entry point to the main process?

Check the package.json file:

Which points to:

Note: Everything in the src/browser directory is executed in the main process. Stuff in just the src directory is for the renderer process.

Is it possible to have compiled JavaScript files and start atom from them?

You could probably cobble something like this together, but then you’re not profiling Atom’s actual startup performance.

How can I set --log-timer-events for the main process?

Have you noticed the --profile-startup flag in the Atom command-line help?

$ atom --help
Atom Editor v1.7.0-dev-627adc6

Usage: atom [options] [path ...]

One or more paths to files or folders may be specified. If there is an
existing Atom window that contains all of the given folders, the paths
will be opened in that window. Otherwise, they will be opened in a new

Environment Variables:

  ATOM_DEV_RESOURCE_PATH  The path from which Atom loads source code in dev mode.
                          Defaults to `~/github/atom`.

  ATOM_HOME               The root path for all configuration files and folders.
                          Defaults to `~/.atom`.

  -1, --one                  This option is no longer supported.                           [boolean]
  --include-deprecated-apis  This option is not currently supported.                       [boolean]
  -d, --dev                  Run in development mode.                                      [boolean]
  -f, --foreground           Keep the browser process in the foreground.                   [boolean]
  -h, --help                 Print this usage message.                                     [boolean]
  -l, --log-file             Log all output to file.                                        [string]
  -n, --new-window           Open a new window.                                            [boolean]
  --profile-startup          Create a profile of the startup execution time.               [boolean]
  -r, --resource-path        Set the path to the Atom source directory and enable dev-mode. [string]
  --safe                     Do not load packages from ~/.atom/packages or ~/.atom/dev/packages.
  --portable                 Set portable mode. Copies the ~/.atom folder to be a sibling of the
                             installed Atom location if a .atom folder is not already there.
  -t, --test                 Run the specified specs and exit with error code on failures. [boolean]
  --timeout                  When in test mode, waits until the specified time (in minutes) and
                             kills the process (exit code: 130).                            [string]
  -v, --version              Print the version information.                                [boolean]
  -w, --wait                 Wait for window to be closed before returning.                [boolean]
  --clear-window-state       Delete all Atom environment state.                            [boolean]
  -a, --add                  Open path as a new project in last used window.               [boolean]

What will it take to implement a decent RegExp engine for find/replace in Atom?

Thanks a lot. I tried --profile-startup, but I believe its result is based on the sampling profiler with --prof flag. I am more curious about seeing the breakdown showing time spent on parsing, compilation, inline cache misses, etc., which can be obtained by --log-timer-events flag. How do I start atom with Chromium or V8 flags set from the beginning?


There’s this document also:

But it doesn’t look like --log-timer-events is supported. You could try it anyway.