Skip to content

Performance optimization with slice #30

@proyb6

Description

@proyb6

Is it possible to improve performance if the router could convert string to bytes using to_slice?

From the benchmark, to_slice would cost <4 nanoseconds and efficient to compare using ==

Range  17.51M ( 57.11ns) (±10.77%)  32 B/op  14.44× slower
Slice     252.8M (  3.96ns) (± 5.81%)   0 B/op        fastest

Range:
key[0..-2]

Slice:
(key.to_slice)[0,key.size-2]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions