Skip to content

Commit

Permalink
Merge pull request #175 from jcplist/zh_tw
Browse files Browse the repository at this point in the history
Fix typo for ch13-04
  • Loading branch information
CYBAI authored Jul 13, 2023
2 parents 5bc3428 + 76ad54d commit fc2bc51
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ch13-04-performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test bench_search_for ... bench: 19,620,300 ns/iter (+/- 915,700)
test bench_search_iter ... bench: 19,234,900 ns/iter (+/- 657,200)
```

疊代器版本竟然比較快一些!我們在此不會解釋評測的程式碼,因為這裡的重點不再於證明這兩種版本是一樣快的,而是要理解這兩種實作對效能的影響。
疊代器版本竟然比較快一些!我們在此不會解釋評測的程式碼,因為這裡的重點不在於證明這兩種版本是一樣快的,而是要理解這兩種實作對效能的影響。

要做更全面的評測的話,你應該要檢查使用不同大小的不同文字來作為 `contents`、不同單字與不同長度來作為 `query`,以及所有各式各樣的可能性。這邊的重點在於:疊代器雖然是高階抽象,但其編譯出來的程式碼與你親自寫出低階的程式碼幾乎相同。疊代器是 Rust 其中一種**零成本抽象**(zero-cost abstractions),這指的是使用的抽象不會在執行時有額外的開銷。這是 C++ 的初始設計暨實作者 Bjarne Stroustrup 在《Foundations of C++》(2012)書中所定義的**零開銷**(zero-overhead)的概念:

Expand Down

0 comments on commit fc2bc51

Please sign in to comment.