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

  Рет қаралды 3,399

Michael Mullin

Michael Mullin

Күн бұрын

In this video I introduce you to rust microbenchmarking with cargo criterion, and answer the question "Should I use to_string() or to_owned() on my &str?"
You can get the code here:
github.com/mas...

Пікірлер: 14
@masmullin
@masmullin 2 жыл бұрын
Lol Bennchmarks. I'm keeping it.
@karelhrkal8753
@karelhrkal8753 2 жыл бұрын
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.
@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!
@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.
@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
@0xccd
@0xccd 2 жыл бұрын
Existencial question answered. Thanks!
@loarca11
@loarca11 2 жыл бұрын
Such a nice presentation, for real man, I really appreciate it!
@okarakoo
@okarakoo 2 жыл бұрын
Real interesting, thank you. As an aside, what's the coding font you are using? The curly brackets look sharp! :-)
@masmullin
@masmullin 2 жыл бұрын
It's called lilex.
@yapayzeka
@yapayzeka 2 жыл бұрын
perfect explanation. thank you.
@GlobalYoung7
@GlobalYoung7 2 жыл бұрын
thank you 😀👍
@bleonkurta6814
@bleonkurta6814 2 жыл бұрын
i learned a lot
@michaelmueller9635
@michaelmueller9635 Жыл бұрын
Great vid, thx.
The Performance overhead of WASM over Native Rust
30:57
Michael Mullin
Рет қаралды 15 М.
Rust: The Dangers of Early Performance Optimization
36:22
Michael Mullin
Рет қаралды 7 М.
when you have plan B 😂
00:11
Andrey Grechka
Рет қаралды 67 МЛН
HAH Chaos in the Bathroom 🚽✨ Smart Tools for the Throne 😜
00:49
123 GO! Kevin
Рет қаралды 16 МЛН
GIANT Gummy Worm Pt.6 #shorts
00:46
Mr DegrEE
Рет қаралды 100 МЛН
Plug WASM into Rust with wit-bindgen
35:15
Michael Mullin
Рет қаралды 2,9 М.
Profiling Rust Programs with valgrind, heaptrack, and hyperfine
23:39
Brent Westbrook
Рет қаралды 3,7 М.
Fundamentals of asynchronous Execution | Advanced Rust Part 5
27:56
Green Tea Coding
Рет қаралды 2,3 М.
Proving Performance - FOSDEM 2024 - Rust Dev Room
40:46
Nikolai Vazquez
Рет қаралды 3,8 М.
Rust Allocators and Memory Management
43:51
Michael Mullin
Рет қаралды 9 М.
Comparing Divan and Criterion
13:48
chris biscardi
Рет қаралды 3,3 М.
Lets Code Ransomware in Rust
1:36:54
Michael Mullin
Рет қаралды 6 М.
Intro To Rust Cryptography: Hashing with SHA2
1:01:30
Michael Mullin
Рет қаралды 2,1 М.
😱ЭТО СМАРТФОНЫ SAMSUNG!
1:00
Thebox - о технике и гаджетах
Рет қаралды 2,1 МЛН
Выпрыгивает ли аккумулятор в iPhone 16?
0:43
ÉЖИ АКСЁНОВ
Рет қаралды 2,2 МЛН
Evolution of PhoneVision
0:18
PhoneVision
Рет қаралды 803 М.