I don't know if this is a DevTools issue or something else, but I'm also not sure how to determine which.
When running tests, CPU profiling never seems to collect any data. For example given a sample project with a bin/main.dart that calls a function in lib that blocks for 5s, and a test that does the same:
bin/main.dart
import 'package:cpu_profile/cpu_profile.dart' as cpu_profile;
void main(List<String> arguments) {
print('starting'); // breakpoint
cpu_profile.calculate();
print('done!'); // breakpoint
}
lib/cpu_profile.dart
int calculate() {
var start = DateTime.now();
while (start.difference(DateTime.now()).inSeconds.abs() < 5) {}
return 6 * 7;
}
test/cpu_profile_test.dart
import 'package:cpu_profile/cpu_profile.dart' as cpu_profile;
import 'package:test/test.dart';
void main() {
test('calculate', () {
print('starting'); // breakpoint
cpu_profile.calculate();
print('done!'); // breakpoint
});
}
For bin/main.dart:
- Open
bin/main.dart
- Add breakpoints on the marked lines
- Run in debug mode and hit the first breakpoint
- Open DevTools CPU profile, enable profiling, and start recording
- Resume execution and wait for it to hit the second breakpoint
- Stop CPU profiling and observe the results
Perform the same steps but using the test instead, and the profiler doesn't show any data:

I don't know if this is a DevTools issue or something else, but I'm also not sure how to determine which.
When running tests, CPU profiling never seems to collect any data. For example given a sample project with a
bin/main.dartthat calls a function inlibthat blocks for 5s, and a test that does the same:bin/main.dart
lib/cpu_profile.dart
test/cpu_profile_test.dart
For
bin/main.dart:bin/main.dartPerform the same steps but using the test instead, and the profiler doesn't show any data: