measureDrawingPerformance static method

void measureDrawingPerformance(
  1. Canvas canvas,
  2. Drawable drawable,
  3. Paint pathPaint,
  4. Paint fillPaint, {
  5. String? label,
})

Performance monitoring for web

Implementation

static void measureDrawingPerformance(
  Canvas canvas,
  Drawable drawable,
  Paint pathPaint,
  Paint fillPaint,
  {String? label}
) {
  if (isWeb) {
    final stopwatch = Stopwatch()..start();
    canvas.drawRoughOptimized(drawable, pathPaint, fillPaint);
    stopwatch.stop();

    if (kDebugMode) {
      print('${label ?? 'Drawing'} took ${stopwatch.elapsedMicroseconds}μs');
    }
  } else {
    // Use standard Rough extension for non-web platforms
    canvas.drawRough(drawable, pathPaint, fillPaint);
  }
}