hyj1991 / v8-profiler-next

node bindings for the v8 profiler
MIT License
219 stars 21 forks source link

Empty cpu profile in chrome devtool #70

Open darren-fp opened 5 months ago

darren-fp commented 5 months ago

I tried to generate a cpu profile using the example here and it outputedt a cpu profile roughly 1.3MB in size but for some reason the cpu profile seems to be empty in chrome devtools

image

CPU profile: checkboxgroup.cpuprofile

This is how I instrumented the profiler

import * as fs from 'fs';
import * as v8Profiler from 'v8-profiler-next';

v8Profiler.setGenerateType(1);
const title = 'checkboxgroup';

describe('CheckboxGroup', () => {
  v8Profiler.startProfiling(title, true);
  afterAll(() => {
    const profile = v8Profiler.stopProfiling(title);
    profile.export(function (error, result: any) {
      // if it doesn't have the extension .cpuprofile then
      // chrome's profiler tool won't like it.
      // examine the profile:
      //   Navigate to chrome://inspect
      //   Click Open dedicated DevTools for Node
      //   Select the profiler tab
      //   Load your file
      fs.writeFileSync(`${title}.cpuprofile`, result);
      profile.delete();
    });
  });

  // tests...
  it('should...')
});

These are the versions that I am using

Is there something wrong that I am doing here? Thanks in advance!

windschaser commented 4 months ago

Same problem. Just use Chrome with older version, the profile displays well on version 101 base on my test.