Skip to content

bad performance of byte and integer to_string() vs str literal to_string() #73533

Closed
@pickfire

Description

@pickfire

Based on #73462

pub fn conv() -> String {
    b'a'.to_string()
}
pub fn conv() -> String {
    10.to_string()
}

Not sure if we can do much about integer to string but I bet we can do something for byte to string.

test tests::bench_byte_to_string ... bench:      51,257 ns/iter (+/- 1,623)
test tests::bench_char_to_string ... bench:      43,246 ns/iter (+/- 7,624)
test tests::bench_int_to_string  ... bench:      52,218 ns/iter (+/- 3,077)
test tests::bench_str_to_string  ... bench:      15,701 ns/iter (+/- 380)

(note that char benchmark is not updated with the latest specialization update by @lzutao)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UnicodeArea: UnicodeI-slowIssue: Problems and improvements with respect to performance of generated code.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions