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

请教下作者实现的STL相比标准库的STL整体性能略优,可能是哪些方面导致的 #142

Open
Lv-Yinghao opened this issue Dec 28, 2023 · 5 comments

Comments

@Lv-Yinghao
Copy link

Lv-Yinghao commented Dec 28, 2023

面试的时候写到这个项目,被面试官问懵了

@Adeshen
Copy link

Adeshen commented Dec 28, 2023 via email

@myc13381
Copy link

我也想知道为什么,作者能否告知一二呢? :)

@frederick-vs-ja
Copy link
Contributor

首先看下是不是 debug 模式测的。
如果是的话,那原因就是标准库实现在 debug 模式增加了很多迭代器检查机制,而 MyTinySTL 没有。

@Lv-Yinghao
Copy link
Author

Lv-Yinghao commented Jan 12, 2024 via email

@Alinshans
Copy link
Owner

Alinshans commented Mar 6, 2024

首先测试并不完整,只测试了很多int型容器,而且大体上大家用的算法都差不多的 时间复杂度都一样 大差不差,然后我这里检查没有太多,逻辑比较干净,顶多只是调一些数值上的策略,比如扩容倍数、初始化容量、哈希密度、插排阈值之类的,所以偶尔有一些比标准库快也正常,但也快不了多少,也有不少打不过的,标准库还是很牛逼的,我这随便写的哪里敢碰瓷标准库,当个玩具就行了 😢

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

No branches or pull requests

5 participants