堆栈/堆性能问题的对象 [英] object on stack/heap performance problems
问题描述
嗨!
我正在为我的大学开发一些数字运算算法,
我把处理器放到了一个类中。
测试时,我在堆栈上创建了
对象时发现了一个非常严重的性能问题。
我上传了一个测试档案在这里: http://digitus.itk.ppke.hu/~ oroba / stack_test.zip
在里面你会找到数字cruncher类(CNN在cnn.h和
cnn.cpp) ,以及两个测试文件:test_slow.cpp和test_fast.cpp。
它们仅在创建处理器对象的位置有所不同。其中一个,它是在堆栈上创建的
,另一个是在堆上创建的。然而,
当我调用成员函数进程()时,性能差异
是5x !!!
可以有人对物体布局有更高的了解,无论如何,
告诉我为什么会这样?
-
提前致谢,
B.
On Sun,2007年7月1日05:51:29 -0700, orobalage写道:
嗨!
我正在为我的大学开发一些数字运算算法,
我把处理器放到了一个类中。
在测试时,当在堆栈上创建
对象时,我发现了一个非常严重的性能问题。 br />
我在这里上传了一个测试档案: http://digitus.itk.ppke.hu/~oroba/stack_test.zip
在里面你会找到数字cruncher类(CNN in CNN。 h和
cnn.cpp),以及两个测试文件:test_slow.cpp和test_fast.cpp。
它们仅在创建处理器对象的位置有所不同。其中一个,它是在堆栈上创建的
,另一个是在堆上创建的。然而,
当我调用成员函数进程()时,性能差异
是5x !!!
可以有人对物体布局有更高的了解,无论如何,
告诉我为什么会这样?
很奇怪。在我的系统上用g ++编译产生差不多20倍。
-
令人讨厌的用户
< blockquote> or*******@gmail.com 写道:
嗨!
我正在为我的大学开发一些数字运算算法,
我把处理器放到了一个类中。
测试时,我在堆栈上创建了
对象时发现了一个非常严重的性能问题。
I在此处上传了一个测试档案: http://digitus.itk.ppke .hu / ~oroba / stack_test.zip
在里面你会找到数字cruncher类(cnn.h中的CNN和
cnn.cpp),以及两个测试文件:test_slow.cpp和test_fast.cpp。
它们仅在创建处理器对象的位置有所不同。其中一个,它是在堆栈上创建的
,另一个是在堆上创建的。然而,
当我调用成员函数进程()时,性能差异
是5x !!!
可以有人对物体布局有更高的了解,无论如何,
告诉我为什么会这样?
-
提前致谢,
B.
好吧,似乎我无法重现你刚才描述的内容:
benben @ watersidem
g ++ main_fast.cpp cnn.cpp -O2 -o fast
benben @ watersidem
Hi!
I was developing some number-crunching algorithms for my university,
and I put the processor into a class.
While testing, I found a quite *severe performance problem* when the
object was created on the stack.
I uploaded a test archive here: http://digitus.itk.ppke.hu/~oroba/stack_test.zip
Inside you''ll find the number cruncher class (CNN in cnn.h and
cnn.cpp), as well as two test files: test_slow.cpp and test_fast.cpp.
They differ ONLY in where the processor object is created. In one, it
is created on the stack, in the other, it is created on the heap. Yet,
when I call the member function process(), the performance difference
is 5x!!!
Can someone with a higher knowledge of object layout and whatsoever,
tell me why this is happening?
--
Thanks in advance,
B.
On Sun, 01 Jul 2007 05:51:29 -0700, orobalage wrote:
Hi!
I was developing some number-crunching algorithms for my university,
and I put the processor into a class.
While testing, I found a quite *severe performance problem* when the
object was created on the stack.
I uploaded a test archive here: http://digitus.itk.ppke.hu/~oroba/stack_test.zip
Inside you''ll find the number cruncher class (CNN in cnn.h and
cnn.cpp), as well as two test files: test_slow.cpp and test_fast.cpp.
They differ ONLY in where the processor object is created. In one, it
is created on the stack, in the other, it is created on the heap. Yet,
when I call the member function process(), the performance difference
is 5x!!!
Can someone with a higher knowledge of object layout and whatsoever,
tell me why this is happening?
Weird. Compiled with g++ on my system yields a difference of almost 20x.
--
Obnoxious User
or*******@gmail.com wrote:Hi!
I was developing some number-crunching algorithms for my university,
and I put the processor into a class.
While testing, I found a quite *severe performance problem* when the
object was created on the stack.
I uploaded a test archive here: http://digitus.itk.ppke.hu/~oroba/stack_test.zip
Inside you''ll find the number cruncher class (CNN in cnn.h and
cnn.cpp), as well as two test files: test_slow.cpp and test_fast.cpp.
They differ ONLY in where the processor object is created. In one, it
is created on the stack, in the other, it is created on the heap. Yet,
when I call the member function process(), the performance difference
is 5x!!!
Can someone with a higher knowledge of object layout and whatsoever,
tell me why this is happening?
--
Thanks in advance,
B.
Well, it seems that I cannot reproduce what you just described:
benben@watersidem
g++ main_fast.cpp cnn.cpp -O2 -o fast
benben@watersidem
这篇关于堆栈/堆性能问题的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!