Forums

CPU allowance calculation

Hello, recently my application has got to tarpit. I'd like to know few things: 1. How can I locally calculate CPU time my script takes, so I can improve it? Would local results be equal to results at PythonAnywhere 2. How can I upgrade to plan with more CPU seconds. I mean I've already paid for Hacker plan, how should I pay n more $ for custom plan?

Thanks for the message!

  1. It's hard to compare local CPU times with what you'll get on PythonAnywhere, because different processors take different amounts of time to do the same stuff. If you have an Intel chip they'll probably scale roughly linearly -- that is, if something takes 2 CPU-seconds locally and 1.5 CPU-seconds on PythonAnywhere, then something that takes 20 seconds locally will probably take something like 15 seconds on PythonAnywhere, but even that might not quite work out, especially if you're running a different operating system. Probably best to measure PythonAnywhere time to PythonAnywhere time. You can find out exactly how many CPU-seconds a particular program takes by running it from a Bash console using the time command. For example:

    $ time python2.7 foo.py
    real    0m7.647s
    user    0m4.111s
    sys     0m0.014s
    

    This means that the program took 7.647 seconds to run, of which the CPU was busy (that is, consuming CPU-seconds) for 4.111 + 0.014 = 4.125 seconds.

  2. To upgrade your CPU-seconds, just go to the "Account" page and click on the "Customize your plan" button, inside the box for the account type you currently have. This will pop up a window where you can choose how many CPU seconds you get, and show you the price. You can then click the "Switch to this plan" button, which will take you through credit card or PayPal authorization again, and you're all set. You will be charged the new price as of your next billing date.