Should you use to_string() or .to_owned? Intro to Rust Micro-benchmarking w/ Criterion:

Поділитися
Вставка
  • Опубліковано 3 лис 2024

КОМЕНТАРІ • 14

  • @masmullin
    @masmullin  2 роки тому +3

    Lol Bennchmarks. I'm keeping it.

  • @loarca11
    @loarca11 2 роки тому

    Such a nice presentation, for real man, I really appreciate it!

  • @karelhrkal8753
    @karelhrkal8753 2 роки тому +4

    4:10 you should use Vec::with_capacity when you know how big the vector is going to be to prevent unnecessary allocations. In this case, that should be len * symbol.len_utf8(). Also you are encoding the char to utf8 in every iteration of the loop, which is like ... why.

  • @Wodziwob
    @Wodziwob Рік тому

    Awesome breakdown. I'm new to rust and I've heard tales of the speed difference so I really appreciate seeing the truth.
    Fwiw in the part about the dictionary definition of idiomatic, I read "distinctive idiomatic dialogue" as an example of how to use idiomatic in a sentence, not an example of idiomatic speech itself. Or maybe the dictionary author is a rustacean, since they say "idiomatic" so much.

  • @0xccd
    @0xccd 2 роки тому

    Existencial question answered. Thanks!

  • @luckystrike91
    @luckystrike91 Рік тому

    I have another question about performance: why BufReader::lines() returns String? I don't need a growable buffer, i need an immutable view into string content!

  • @yapayzeka
    @yapayzeka 2 роки тому

    perfect explanation. thank you.

  • @qwertyqwerty-jp8pr
    @qwertyqwerty-jp8pr 2 роки тому

    I think ToString as something being like Display but put it inside a string. ToOwned is more clear if you want to turn &str into String because you are not casting to string, you're simply trying to take ownership.

  • @samuelgunter
    @samuelgunter Рік тому

    I'd look at the generated assembly and see if it's exactly the same, that'd be an easy way to tell

  • @okarakoo
    @okarakoo 2 роки тому

    Real interesting, thank you. As an aside, what's the coding font you are using? The curly brackets look sharp! :-)

  • @GlobalYoung7
    @GlobalYoung7 2 роки тому

    thank you 😀👍

  • @bleonkurta6814
    @bleonkurta6814 2 роки тому

    i learned a lot

  • @michaelmueller9635
    @michaelmueller9635 2 роки тому

    Great vid, thx.