ChartRuntimePerformanceSummary.fromRuntimeInputs constructor

ChartRuntimePerformanceSummary.fromRuntimeInputs({
  1. required int sourceDataPointCount,
  2. int? effectiveDataPointCount,
  3. int? sampleInputPointCount,
  4. required int renderedDataPointCount,
  5. required int seriesCount,
  6. required bool configSampledData,
  7. required bool payloadWasNormalized,
  8. required bool payloadChanged,
  9. required ChartDataProcessingCacheStats processingCacheStats,
  10. ChartRenderCacheStats? renderCacheStats,
  11. PictureCacheStats? pictureCacheStats,
  12. ChartRuntimePerformancePolicy policy = ChartRuntimePerformancePolicy.defaults,
})

Implementation

factory ChartRuntimePerformanceSummary.fromRuntimeInputs({
  required int sourceDataPointCount,
  int? effectiveDataPointCount,
  int? sampleInputPointCount,
  required int renderedDataPointCount,
  required int seriesCount,
  required bool configSampledData,
  required bool payloadWasNormalized,
  required bool payloadChanged,
  required ChartDataProcessingCacheStats processingCacheStats,
  ChartRenderCacheStats? renderCacheStats,
  PictureCacheStats? pictureCacheStats,
  ChartRuntimePerformancePolicy policy =
      ChartRuntimePerformancePolicy.defaults,
}) {
  final renderedOutputRatio = _safeRatio(
    renderedDataPointCount,
    sourceDataPointCount,
  );
  final renderedReductionRatio = sourceDataPointCount <= 0
      ? 0.0
      : (1 - renderedOutputRatio).clamp(0.0, 1.0).toDouble();
  final samplingOutputRatio = sampleInputPointCount == null
      ? null
      : _safeRatio(renderedDataPointCount, sampleInputPointCount);
  final samplingReductionRatio = sampleInputPointCount == null
      ? null
      : (1 - samplingOutputRatio!).clamp(0.0, 1.0).toDouble();
  final largeUnsampled =
      sourceDataPointCount >= policy.normalizedLargeDatasetPointThreshold &&
      !configSampledData;
  final processingCacheMemoryPressure = _safeRatioOrNull(
    processingCacheStats.currentBytes,
    processingCacheStats.maxBytes,
  );
  final pictureCacheMemoryPressure = pictureCacheStats == null
      ? null
      : _safeRatioOrNull(
          pictureCacheStats.currentMemoryBytes,
          pictureCacheStats.maxMemoryBytes,
        );
  final renderCacheHitRate = renderCacheStats == null
      ? null
      : _renderCacheHitRate(renderCacheStats);
  final renderCacheRequests = renderCacheStats == null
      ? null
      : _renderCacheRequests(renderCacheStats);
  final recommendation = _runtimePerformanceRecommendation(
    sourceDataPointCount: sourceDataPointCount,
    largeUnsampled: largeUnsampled,
    processingCacheStats: processingCacheStats,
    processingCacheMemoryPressure: processingCacheMemoryPressure,
    pictureCacheMemoryPressure: pictureCacheMemoryPressure,
    renderCacheHitRate: renderCacheHitRate,
    renderCacheRequests: renderCacheRequests,
    policy: policy,
  );
  final severity = _runtimePerformanceSeverity(
    recommendation,
    payloadChanged: payloadChanged,
  );

  return ChartRuntimePerformanceSummary(
    sourceDataPointCount: sourceDataPointCount,
    effectiveDataPointCount: effectiveDataPointCount,
    sampleInputPointCount: sampleInputPointCount,
    renderedDataPointCount: renderedDataPointCount,
    seriesCount: seriesCount,
    configSampledData: configSampledData,
    payloadWasNormalized: payloadWasNormalized,
    payloadChanged: payloadChanged,
    largeUnsampled: largeUnsampled,
    renderedOutputRatio: renderedOutputRatio,
    renderedReductionRatio: renderedReductionRatio,
    samplingOutputRatio: samplingOutputRatio,
    samplingReductionRatio: samplingReductionRatio,
    processingCacheHitRate: processingCacheStats.hitRate,
    extractionCacheHitRate: processingCacheStats.extractionHitRate,
    processingCacheMemoryPressure: processingCacheMemoryPressure,
    renderCacheHitRate: renderCacheHitRate,
    renderCacheRequests: renderCacheRequests,
    pictureCacheMemoryPressure: pictureCacheMemoryPressure,
    severity: severity,
    recommendation: recommendation,
    policy: policy,
  );
}