Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Automatically select main isolate instead of the test runner isolate when connecting to test runs

Đang mở
#9,747 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
dart
Lĩnh vực
devtools, performance, testing

Hướng nghiên cứu

Tái hiện sự cố với bin/main.dart và test/cpu_profile_test.dart, làm theo các bước về breakpoint và lập hồ sơ CPU trong báo cáo. Trước tiên, hãy theo dõi cách DevTools kết nối với một lần chạy kiểm thử và chọn một isolate; hoàn tất khi việc lập hồ sơ lần chạy kiểm thử ghi nhận phần xử lý trong cpu_profile.calculate() và hiển thị dữ liệu giống như chương trình độc lập.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

cross-screen P2

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
Image

Perform the same steps but using the test instead, and the profiler doesn't show any data:

Image
Ngôn ngữ chính
Dart
Star
1.7k
Fork
405
Merge trung bình
4 ngày 21 giờ
Pull request đã merge (30 ngày)
15

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của flutter/devtools

Tất cả issue của flutter/devtools

Issue tương tự

Thêm issue về Dart

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.