Skip to content

Implement a class for the Profiler API in dwds #674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
willdrach-wk opened this issue Sep 19, 2019 · 0 comments
Open

Implement a class for the Profiler API in dwds #674

willdrach-wk opened this issue Sep 19, 2019 · 0 comments
Labels
package:dwds type-enhancement A request for a change that isn't a bug

Comments

@willdrach-wk
Copy link

The Chrome DevTools protocol has a Profiler API, which adds a host of helpful methods for analyzing code. In our case in particular, we would like to make use of Profiler.takePreciseCoverage and Profiler.startPreciseCoverage to generate code coverage reports.

Overall I think this would look very similar to the Sources class but even simpler. A basic implementation of this API could be as simple as this:

class Profiler {
  bool _profilerEnabled = false;
  final RemoteDebugger _remoteDebugger;

  Profiler(this._remoteDebugger);

  Future startProfiler() async {
    if (_profilerEnabled) {
      return;
    }
    _profilerEnabled = true;
    await _remoteDebugger.sendCommand('Profiler.enable');
  }

  Future startPreciseCoverage() async {
    await startProfiler();
    return _remoteDebugger.sendCommand('Profiler.startPreciseCoverage');
  }

  Future takePreciseCoverage() async {
    await startProfiler();
    return _remoteDebugger.sendCommand('Profiler.takePreciseCoverage');
  }
}

Obviously there's a million other things you could add and use, but really this is all we'd need to help get the information we want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:dwds type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants