<div dir="ltr">You are comparing a native-compiled C++ program that works on small arrays of raw numbers with an interpreted Erlang program that traverses linked lists of tagged numbers. The only surprise is that the difference is _only_ a factor 10. (And if the C code was using integers instead of double precision floats, it would be even faster.)<br></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><br>        /Richard</div></div>
<br><div class="gmail_quote">2016-11-11 8:26 GMT+01:00 谈广云 <span dir="ltr"><<a href="mailto:fw339tgy@126.com" target="_blank">fw339tgy@126.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>i campare the erlang's computing with c++ </div><div><br></div><div>erlang run 100000000 time the <span style="line-height:23.8px">test_sum_0</span></div><div><br></div><div><div>test_sum_0(N) -></div><div>  bp_eva_delta([1,2,3,4],[3,4,5,<wbr>6],[]),</div><div>  test_sum_0(N-1).</div><div><br></div><div><br></div><div>bp_eva_delta([],_,L) -></div><div><span class="m_1294048474720919507Apple-tab-span" style="white-space:pre-wrap">        </span>lists:reverse(L);</div><div>bp_eva_delta([O|Output],[S|<wbr>Sigma],L) -></div><div><span class="m_1294048474720919507Apple-tab-span" style="white-space:pre-wrap">      </span>bp_eva_delta(Output,Sigma,[S * O * (1-O) |L]).<span class="m_1294048474720919507Apple-tab-span" style="white-space:pre-wrap">    </span></div></div><div><br></div><div><br></div><div><br></div><div><br></div><div>c++ run the same time (<span style="line-height:23.8px">100000000</span><span style="line-height:23.8px"> </span><span style="line-height:1.7">) the s</span>imilar fun ,</div><div><br></div><div><div>for(int i = 0 ;i< 100000000;++i)</div><div><span class="m_1294048474720919507Apple-tab-span" style="white-space:pre-wrap">  </span>{<span class="m_1294048474720919507Apple-tab-span" style="white-space:pre-wrap"> </span></div><div><span class="m_1294048474720919507Apple-tab-span" style="white-space:pre-wrap">           </span>double b[5] = {1,2,3,4,5};</div><div><span class="m_1294048474720919507Apple-tab-span" style="white-space:pre-wrap">         </span>double s[5] = {6,7,8,9,10};</div><div><span class="m_1294048474720919507Apple-tab-span" style="white-space:pre-wrap">                </span>double o[5];</div><div><span class="m_1294048474720919507Apple-tab-span" style="white-space:pre-wrap">               </span>for(int i = 0; i < 5;++i)</div><div><span class="m_1294048474720919507Apple-tab-span" style="white-space:pre-wrap">               </span>{</div><div><span class="m_1294048474720919507Apple-tab-span" style="white-space:pre-wrap">                  </span>o[i] = s[i] * b[i] * (1 - b[i]);</div><div><span class="m_1294048474720919507Apple-tab-span" style="white-space:pre-wrap">           </span>}</div><div><br></div><div><span class="m_1294048474720919507Apple-tab-span" style="white-space:pre-wrap"> </span>}.</div></div><div><br></div><div>the erlang spend 29's , and c++ spend 2.78's.</div><div><br></div><div>why the erlang is so slower than c++?</div><div><br></div><div> Or I do not configure  the right parameter?</div><div><br></div><div><br></div></div><br><br><span title="neteasefooter"><p> </p></span><br>______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>