calculator

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package calculator provides size calculation and efficiency analysis.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatBytes

func FormatBytes(bytes int64) string

FormatBytes formats bytes to human-readable string.

func FormatBytesPrecise

func FormatBytesPrecise(bytes int64) string

FormatBytesPrecise formats bytes with more precision for large values.

Types

type Calculator

type Calculator struct{}

Calculator performs size and efficiency calculations on images.

func NewCalculator

func NewCalculator() *Calculator

NewCalculator creates a new calculator.

func (*Calculator) CalculateEfficiency

func (c *Calculator) CalculateEfficiency(image *models.Image) EfficiencyResult

CalculateEfficiency computes an efficiency score for the image.

func (*Calculator) CalculateSizeBreakdown

func (c *Calculator) CalculateSizeBreakdown(image *models.Image) SizeBreakdown

CalculateSizeBreakdown analyzes the image size by different categories.

type EfficiencyResult

type EfficiencyResult struct {
	Score              float64  `json:"score"`        // 0-100 efficiency score
	WastedSpace        int64    `json:"wasted_space"` // Estimated wasted bytes
	WastedSpacePercent float64  `json:"wasted_space_percent"`
	DuplicateLayers    int      `json:"duplicate_layers"` // Count of potentially duplicate layers
	EmptyLayers        int      `json:"empty_layers"`     // Count of empty/meta layers
	OptimizationTips   []string `json:"optimization_tips"`
}

EfficiencyResult contains efficiency metrics.

type SizeBreakdown

type SizeBreakdown struct {
	TotalSize         int64                        `json:"total_size"`
	LayerCount        int                          `json:"layer_count"`
	SizeByType        map[models.LayerType]int64   `json:"size_by_type"`
	SizeByTypePercent map[models.LayerType]float64 `json:"size_by_type_percent"`
	MetaLayerSize     int64                        `json:"meta_layer_size"`
	DataLayerSize     int64                        `json:"data_layer_size"`
}

SizeBreakdown contains categorized size information.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL