Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(stdlib): Use lookup for integer parsing #100

Merged
merged 1 commit into from
Aug 23, 2024
Merged

Conversation

tibordp
Copy link
Member

@tibordp tibordp commented Aug 23, 2024

Quick microbenchmark

use std::time::Instant;

fn main() {
    let start = Instant::now();
    let sum = 0u64;
    const hexu64 = "ec19cb9f7768724f";
    for i in 0..1000000000 {
        sum += u64::parse_with_radix(hexu64, 16).unwrap();
    }
    println!("sum = {}", sum);
    println!("time = {}", Instant::now().duration_since(&start));
}

Before

sum = 11033462181226632704
time = 00:00:37.924432777

After

sum = 11033462181226632704
time = 00:00:13.741396338

That's quite incredible 🤣

@tibordp tibordp merged commit 682e5d3 into master Aug 23, 2024
8 checks passed
@tibordp tibordp deleted the optimize-int-parsing branch September 27, 2024 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant