Skip to content

testing: be clearer about when Benchmark needs Init #77499

Description

@dominikh

The documentation of testing.Benchmark says that

If f depends on testing flags, then [Init] must be used to register
those flags before calling Benchmark and before calling [flag.Parse].

but doesn't specify what might depend on the flags.

I ran into this when I returned inside a for b.Loop() loop, which tried to log an error, but instead panicked because logging accesses the fullPath flag.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions