[Tutor] Increase speed
Eric Brunson
brunson at brunson.com
Tue Oct 9 16:03:19 CEST 2007
Øyvind wrote:
> Hello.
>
> I have written a simple application that does a number of simple
> calculations. In psudo-code it looks something like below.
>
> The program works fine. However, it seems like I need a supercomputer to
> finish the resultwithin a reasonable timeframe, as the var.txt contains a
> lot of variables that has to be computed. And, since my budget doesn't
> include a supercomputer, I need to optimize the script. I have been able
> to half the running-time by flushing the file more seldom, and a little
> more by try and fail. However, half is still a looong time. I would like
> to increase the speed even more.
>
> Does anyone have any suggestions of what I should do? Is Stackless Python
> an option? Is there some other steps I could take? Some basic steps?
>
I've had quite a bit of success using psyco (google it). It only works
on x86 platforms and I was unsuccessful getting it compiled on Solaris
10 for x86, but I didn't try that hard, if you're on Linux you shouldn't
have many problems. I saw speedups anywhere from 2 to 10 times,
depending on the code.
Hope that helps,e
e.
> Thanks in advance,
> Øyvind
>
> class start:
>
> filles = open("var.txt","r") into memory
>
> def oppned(self):
> return randint(0,1)
>
> def verdier(self):
> increase variable x and y
>
> def verdi(self):
> for i in filles:
> generate random from oppned
> simple calculation
>
> if result 1:
> write result
>
> if result 2:
> generate new random, calculate more
> write result
>
> if result 3:
> write result, use new variable
>
> if __name__ == '__main__':
> n = start()
> for x in range(0,10000):
> n.verdier()
> for y in range(0,100):
> n.verdi()
>
> n.fil.write(result)
> if variable x > 0.32:
> break
>
>
>
>
More information about the Tutor
mailing list