Skip to content

Don't use viper.Get* in tight loops #2495

@bep

Description

@bep

Profiling indicate that using viper.GetBool inside the url funcs (MakePath etc.) have a surprising cost.

Just removing one viper.Get temporary from MakePathSanitized:

benchmark           old ns/op       new ns/op       delta
BenchmarkHugo-4     20347856514     17916615991     -11.95%

benchmark           old allocs     new allocs     delta
BenchmarkHugo-4     66611825       60243953       -9.56%

benchmark           old bytes       new bytes       delta
BenchmarkHugo-4     10282345656     10122546104     -1.55%

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions