Skip to content

Papercuts with #[bench] #7655

Closed
Closed

Description

@catamorphism
  1. #[bench] functions that have the wrong type signature get silently ignored. This should be an error.
  2. Running a compiled thing with #[bench]s in it yields:
running 1 test
test g ... bench: 16 ns/iter (+/- 0)
result: ok. 0 passed; 0 failed; 0 ignored

The last line (0 passed/0 failed/0 ignored) is confusing here, since it did run something.

  1. I don't think there's much documentation of #[bench] -- specifically that you have to compile with --test and run with --bench.

Activity

  1. pnkfelix commented on Sep 24, 2013

    @pnkfelix
    Contributor

    visiting for triage, email from 2013 sep 09. I agree, the above problems do indeed look like papercuts.

  2. pnkfelix commented on Oct 11, 2013

    @pnkfelix
    Contributor

    also, it might be nice if the benchmark output right-aligned the decimal points in the numbers, for ease of quick comparison by eye.

    Doing the above in full generality is probably not worthwhile, since it requires knowing how many digits the maximal output has before you present any results. (It also requires knowing the longest test name, but that is easier to predict accurately. ;)

    But even just guessing a reasonable value for the max number of digits for ns/iter, e.g. 9 or 10, and then using that for format width padding, would be step forward.

  3. pnkfelix commented on Oct 15, 2013

    @pnkfelix
    Contributor

    Also, the presentation of 0 ns/iter for benchmark runs that actually timed out is a pretty serious papercut; see for example discussion on #9653

  4. emberian commented on Mar 18, 2014

    @emberian
    Contributor

    The testing guide now has docs. The new result line is test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured. I've opened #12997 for the typechecking thing, closing.

  5. added a commit that references this issue on Sep 28, 2021
    e8cd4e5
  6. added a commit that references this issue on Aug 21, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions