-
Notifications
You must be signed in to change notification settings - Fork 313
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
libcstl效率问题 #11
Comments
你在 void test_cpp_stl 里手动调用两个 vector 的析构函数试试? |
还是差不多的。 |
确实性能差了很多啊~~vector在栈上,自动释放的,手动调用删除会程序崩溃的。 要42s左右./configure --disable-assert |
想请问一下,libcstl和C++的STL之间的效率差异是由于什么造成的? |
stl的容器元素类型是静态的,在编译的时候就已经确定了,但是libcstl确实动态的,在运行的时候动态确定,我认为这是主要的问题,还有可能就是作者水平有限,选择的结构或者算法不好。 |
优化了类型解析部分的代码,性能提高了一倍,不过还是要比stl效率差。 |
libcstl-2.3以及后续版本要进行优化 |
runtime = 0.022 ms cpp |
我不太懂为什么libcstl要加上一个动态类型分析,原本C语言就无法实现想C++那样的完整的泛型机制,增加的这个动态类型识别大大的提高了程序的负担,而且还显得有些鸡肋,按照这样的一个运行效率,反而可用性不高了 |
[wb@ActiveSys libcstl]$ cat test_cpp_stl.cpp
[wb@ActiveSys libcstl]$ cat test_cstl.c
[wb@ActiveSys libcstl]$ time ./test_cpp_stl
real 0m0.342s
user 0m0.303s
sys 0m0.021s
[wb@ActiveSys libcstl]$ time ./test_cstl
real 0m44.984s
user 0m42.134s
sys 0m0.039s
The text was updated successfully, but these errors were encountered: