Skip to content

state.PauseTiming() and state.ResumeTiming() take a long time #179

@izaid

Description

@izaid

I'm trying to benchmark a custom map type. I basically want to see how long it takes to look up random keys.

To do so, I'm generating random keys in the state.KeepRunning() loop. I obviously don't want the random key generation to be added to the overall time of the benchmark. To prevent this, I tried to use state.PauseTiming() and state.ResumeTiming(), but I found using those functions added 100s of nanoseconds to my benchmark -- which is much more than the map lookup itself.

Is this a problem with these functions? Or should I be generating my keys a different way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions