From 87cb6b02a6b562829af0f7c266ab0e12f46b43b5 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Sat, 5 Jun 2021 12:22:13 -0400 Subject: [PATCH] Add example of running with cpuprofile enabled --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index f7ffe4c4..019f9b8e 100644 --- a/README.md +++ b/README.md @@ -232,6 +232,25 @@ stdout and stderr output: stderr, not the `test2json` stdout). Any stderr produced by tests is not considered an error (it will be in the `test2json` stdout). +**Example: run tests with profiling enabled** + +Using a `profile.sh` script like this: + +```sh +#!/usr/bin/env bash +set -eu + +for pkg in $(go list "$@"); do + dir="$(go list -f '{{ .Dir }}' $pkg)" + go test -json -cpuprofile="$dir/cpu.profile" "$pkg" +done +``` + +You can run: +``` +gotestsum --raw-command ./profile.sh ./... +``` + **Example: using `TEST_DIRECTORY`** ``` TEST_DIRECTORY=./io/http gotestsum