Skip to content

Compiler inlines and optimizes the whole function to return 330 #2

@jhorstmann

Description

@jhorstmann

Rust and its pattern matching is fast, but not that fast ;)

Rustc 1.77 seems to be able to optimize the whole pattern_matching function to the equivalent of return 330.

Rustc 1.78 seems to be able to do the same optimization also for the dynamic_dispatch version.

See https://rust.godbolt.org/z/zTrzhTbze for the assembly output.

A possible improvement to the benchmark could be to change Action to take a parameter, and to tunnel the parameter value through criterion::black_box to avoid compiler optimizations based on that value.

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