Dans l'article <rkdc7poiachh.1x4jtxjzaf3zo.dlg at 40tude.net>, Mike a ?crit :

This is an error function approximation, which gets called around 1.5
billion times during the simulation, and takes around 3500 seconds (just
under an hour) to complete. While trying to speed things up, I created a
simple test case with the code above and a main function to call it 10
million times. The code takes roughly 210 seconds to run.
Hi there.

This is pure numerical computation, it is therefore a job for psyco

I've made a quick test, cut'n'pasted your code in a small python module,
added the following lines:
def run():
results = []
for i in xrange(10000000):
x = i/100. # apply erfc to a float
y = erfc(x)

if __name__ == '__main__':
at the end. So I'm basically calling erfc 1 million times, and not doing
much with the result. On my older machine (1.1GHz Celeron), this takes
13 seconds.

By adding the following 2 lines at the top of the script:
import psyco
I get down to under 4 seconds.

This is obviously not as good as you'd get with c#, but it's still a
great gain with not too much work, I think.

Alexandre Fayolle
LOGILAB, Paris (France).
http://www.logilab.com http://www.logilab.fr http://www.logilab.org
D?veloppement logiciel avanc? - Intelligence Artificielle - Formations

Search Discussions

Discussion Posts


Follow ups

Related Discussions



site design / logo © 2022 Grokbase