stats

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package stats provides performance tracking and statistics for link checking operations. It captures timing information for each phase of execution, memory usage, and throughput metrics to help identify bottlenecks and optimize performance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatBytes

func FormatBytes(bytes uint64) string

FormatBytes formats bytes for human-readable display.

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration for display.

Types

type Stats

type Stats struct {
	// Timing for each phase
	ScanStart  time.Time
	ScanEnd    time.Time
	ParseStart time.Time
	ParseEnd   time.Time
	CheckStart time.Time
	CheckEnd   time.Time

	// Counts
	FilesScanned int
	LinksFound   int
	UniqueURLs   int
	Duplicates   int
	Ignored      int

	// Memory stats (captured at end)
	HeapAlloc    uint64
	TotalAlloc   uint64
	NumGC        uint32
	NumGoroutine int
}

Stats holds performance metrics for a link checking session.

func New

func New() *Stats

New creates a new Stats instance.

func (*Stats) AvgResponseTime

func (s *Stats) AvgResponseTime() time.Duration

AvgResponseTime returns the average time per URL check.

func (*Stats) CheckDuration

func (s *Stats) CheckDuration() time.Duration

CheckDuration returns the time spent checking URLs.

func (*Stats) EndCheck

func (s *Stats) EndCheck()

EndCheck marks the end of the URL checking phase and captures memory stats.

func (*Stats) EndParse

func (s *Stats) EndParse(linksFound, uniqueURLs, duplicates, ignored int)

EndParse marks the end of the link parsing phase.

func (*Stats) EndScan

func (s *Stats) EndScan(filesFound int)

EndScan marks the end of the file scanning phase.

func (*Stats) ParseDuration

func (s *Stats) ParseDuration() time.Duration

ParseDuration returns the time spent parsing links from files.

func (*Stats) ScanDuration

func (s *Stats) ScanDuration() time.Duration

ScanDuration returns the time spent scanning for files.

func (*Stats) StartCheck

func (s *Stats) StartCheck()

StartCheck marks the beginning of the URL checking phase.

func (*Stats) StartParse

func (s *Stats) StartParse()

StartParse marks the beginning of the link parsing phase.

func (*Stats) StartScan

func (s *Stats) StartScan()

StartScan marks the beginning of the file scanning phase.

func (*Stats) String

func (s *Stats) String() string

String returns a formatted string representation of the stats.

func (*Stats) ToJSON

func (s *Stats) ToJSON() map[string]any

ToJSON returns a map suitable for JSON serialization.

func (*Stats) TotalDuration

func (s *Stats) TotalDuration() time.Duration

TotalDuration returns the total time from scan start to check end.

func (*Stats) URLsPerSecond

func (s *Stats) URLsPerSecond() float64

URLsPerSecond returns the throughput of URL checking.

Jump to

Keyboard shortcuts

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