diff options
Diffstat (limited to 'content/en/functions/debug')
-rw-r--r-- | content/en/functions/debug/Dump.md | 11 | ||||
-rw-r--r-- | content/en/functions/debug/Timer.md | 37 | ||||
-rw-r--r-- | content/en/functions/debug/_index.md | 12 |
3 files changed, 52 insertions, 8 deletions
diff --git a/content/en/functions/debug/Dump.md b/content/en/functions/debug/Dump.md index ff505a76b..d3161605f 100644 --- a/content/en/functions/debug/Dump.md +++ b/content/en/functions/debug/Dump.md @@ -1,16 +1,13 @@ --- title: debug.Dump description: Returns an object dump as a string. -categories: [functions] +categories: [] keywords: [] -menu: - docs: - parent: functions -function: +action: aliases: [] + related: [] returnType: string signatures: [debug.Dump VALUE] -relatedFunctions: [] --- ```go-html-template @@ -43,8 +40,6 @@ relatedFunctions: [] } ``` - - {{% note %}} Output from this function may change from one release to the next. Use for debugging only. {{% /note %}} diff --git a/content/en/functions/debug/Timer.md b/content/en/functions/debug/Timer.md new file mode 100644 index 000000000..ae6c3188f --- /dev/null +++ b/content/en/functions/debug/Timer.md @@ -0,0 +1,37 @@ +--- +title: debug.Timer +description: Creates a named timer that reports elapsed time to the console. +categories: [] +keywords: [] +action: + aliases: [] + related: [] + returnType: debug.Timer + signatures: [debug.Timer NAME] +--- + +{{< new-in 0.120.0 >}} + +Use the `debug.Timer` function to determine execution time for a block of code, useful for finding performance bottle necks in templates. + +The timer starts when you instantiate it, and stops when you call its `Stop` method. + +```go-html-template +{{ $t := debug.Timer "TestSqrt" }} +{{ range seq 2000 }} + {{ $f := math.Sqrt . }} +{{ end }} +{{ $t.Stop }} +``` + +Use the `--logLevel info` command line flag when you build the site. + +```sh +hugo --logLevel info +``` + +The results are displayed in the console at the end of the build. You can have as many timers as you want and if you don't stop them, they will be stopped at the end of build. + +```text +INFO timer: name TestSqrt total 12.429355ms +``` diff --git a/content/en/functions/debug/_index.md b/content/en/functions/debug/_index.md new file mode 100644 index 000000000..418828515 --- /dev/null +++ b/content/en/functions/debug/_index.md @@ -0,0 +1,12 @@ +--- +title: Debug functions +linkTitle: debug +description: Template functions to debug your templates. +categories: [] +keywords: [] +menu: + docs: + parent: functions +--- + +Use these functions to debug your templates. |