dart-lang / dart-lang/webdev

Implement a class for the Profiler API in dwds

Open
#674 0 comments 0 reactions 0 assignees View on GitHub
package:dwds type-enhancement
Dominant language
Dart
Stars
224
Forks
94
Avg merge
7h 14m
Merged PRs (30d)
2

Description

The Chrome DevTools protocol has a [`Profiler` API](https://chromedevtools.github.io/devtools-protocol/tot/Profiler), 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](https://github.com/dart-lang/webdev/blob/master/dwds/lib/src/debugging/sources.dart) class but even simpler. A basic implementation of this API could be as simple as this:

```Dart
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.

Contributor guide

Open the contributing guide

Research direction

Start by reading dwds/lib/src/debugging/sources.dart and the RemoteDebugger usage it demonstrates. Add a similarly structured, simpler Profiler class that enables the Profiler domain and exposes precise-coverage commands. Done means the class sends the requested protocol commands without enabling the profiler more than once.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
devtools, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.