performance

package module
v0.0.0-...-ae270ae Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Chromium is the Browser value corresponding to Chromium browsers, and try to mimic
	// their Performance implementation.
	Chromium = NewBrowser(true)
	// Gecko is the Browser value corresponding to the firefox browser, and try to mimic
	// its Performance implementation. Firefox's performance doesn't return floats with
	// decimal precision.
	Gecko = NewBrowser(false)
)

Functions

This section is empty.

Types

type Browser

type Browser struct {
	// contains filtered or unexported fields
}

func NewBrowser

func NewBrowser(hasDecimal bool) *Browser

NewBrowser creates a new instance of the Browser struct with the specified decimal precision flag.

func (*Browser) NewPerformance

func (b *Browser) NewPerformance(mode LengthMode) *Performance

NewPerformance creates a new instance of the Performance struct with the specified length mode and the starting time set to the current time.

func (*Browser) TimeOrigin

func (b *Browser) TimeOrigin() float64

TimeOrigin returns a string representation of the current time in milliseconds, with or without decimal precision depending on the associated Browser instance.

func (*Browser) TimeOriginString

func (b *Browser) TimeOriginString() string

TimeOriginString returns a string representation of the current time in milliseconds, with or without decimal precision depending on the associated Browser instance.

type LengthMode

type LengthMode int
const (
	SingleDigitMode LengthMode = iota
	MediumLengthMode
	LargeLengthMode
)

func (LengthMode) Index

func (l LengthMode) Index() int

type Performance

type Performance struct {
	Mode LengthMode
	// contains filtered or unexported fields
}

func (*Performance) Add

func (p *Performance) Add(offset int64)

Add adds the specified offset value to the underlying offset.

func (*Performance) Current

func (p *Performance) Current() float64

Current returns a float of the current offset with the random decimal value added to it, to match the Browser implementation.

func (*Performance) CurrentString

func (p *Performance) CurrentString() string

CurrentString returns a string representation of the current offset value, including the random decimal value generated to match the Browser implementation.

func (*Performance) Min

func (p *Performance) Min(offset int64)

Min subtracts the specified offset value from the underlying offset.

func (*Performance) Now

func (p *Performance) Now() float64

Now returns the elapsed time since the start of the Performance instance, with or without decimal precision depending on the Browser.

Jump to

Keyboard shortcuts

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