• 2020
  • 09/09/2020
  • Public Content

Profiling JavaScript* Code in Node.js*

This recipe provides configuration steps to rebuild
* and enable Intel® VTune™ Amplifier performance analysis for your JavaScript code including mixed-mode call stacks containing JS frames and native frames (native code, for example, system libraries or native libraries called from the JavaScript code).


This section lists the hardware and software tools used for the performance analysis scenario.
  • Application
    . The application is used as a demo and not available for download.
  • JavaScript environment
    version 8.0.0 with Chrome* V8 version
  • Performance analysis tools
    : Intel VTune Amplifier 2018 - Advanced Hotspots analysis
    • For
      downloads and product support, visit
    • All the Cookbook recipes are scalable and can be applied to Intel VTune Amplifier 2018 and higher. Slight version-specific configuration changes are possible.
    • Intel® VTune™ Amplifier has been renamed to Intel® VTune™ Profiler starting with its version for Intel® oneAPI Base Toolkit (Beta). You can still use a standalone version of the VTune Profiler, or its versions integrated into Intel Parallel Studio XE or Intel System Studio.
  • Operating system
    : Windows* 10

Enable VTune Amplifier Support in Node.js

  1. Download
    sources (nightly build).
  2. Run the
    script from the root
    echo vcbuild.bat enable-vtune
    This script builds
    with the
    support to profile JavaScript code.
  • On Linux* systems, avoid using the
    flag with the
    configure flag. This combination is not compatible and causes the
    environment to crash.
  • If you use Microsoft Visual Studio* 2015 IDE or higher, make sure to add
    to the
    #include <string.h> #ifdef WIN32 #define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS #include <hash_map> using namespace std; #else ...

Profile JavaScript Code Running in Node.js

This recipe uses a sample JavaScript application:
function say(word) { console.log("Calculating ..."); var res = 0; for (var i = 0; i < 20000; i++) { for (var j = 0; j < 20000; j++) { res = i * j / 2; } } console.log("Done."); console.log(word); } function execute(someFunction, value) { someFunction(value); } execute(say, "Hello from Node.js!");
To profile this application with the VTune Amplifier:
  1. Launch the VTune Amplifier:
  2. Click the New Project icon on the toolbar to create a new project.
  3. In the
    Analysis Target
    tab, specify
    in the
    field and
    in the
    Application parameters
  4. Switch to the
    Analysis Type
    tab and select the
    Advance Hotspots
    analysis type from the left pane and click
    to run the analysis.
    Advanced Hotspots analysis was integrated into the generic Hotspots analysis starting with Intel VTune Amplifier 2019, and is available via the Hardware Event-Based Sampling collection mode.
When the analysis is complete, the VTune Amplifier opens the result in the default Hotspots viewpoint. Use the
window to explore how the samples are distributed through JavaScript functions. Double-click the function that took the most CPU time to execute to view the source code and identify the hottest code line:

Product and Performance Information


Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804