paulirish / automated-chrome-profiling

Node.js recipes for automating javascript profiling in Chrome
https://github.com/paulirish/automated-chrome-profiling#readme
863 stars 72 forks source link

Timeline data not populated when using Runtime.runScript #12

Open ngryman opened 7 years ago

ngryman commented 7 years ago

Hi Paul,

Awesome resource again!

I would like to trace several scripts. Instead of using Page.navigate I prefer to inject them on the fly. I'm doing so like this:

const frameworkCode = // loaded source
const testCode = // loaded source

Runtime.compileScript({
  expression: `
    ${frameworkCode}
    ${testCode}
  `,
  sourceURL: 'mount-long-sequence.js',
  persistScript: true
})
.then(Runtime.runScript)

But when I use Tracing to fetch timeline data, I don't have any event related to the JavaScript execution 😢 I've tried to play with categories and finally came to the conclusion that for some reason Tracing doesn't catch JavaScript code executed like this. But I may be wrong.

Do you know if it's possible? Am I missing something?

Thanks!

ngryman commented 7 years ago

I created this project based on your resources: https://github.com/ngryman/speedracer. If I could drop the need of a server it would be awesome 🎉

paulirish commented 7 years ago

holy crap this is cool.​