4

Here is the way I try to calculate the time for CPU in Window.

start_time_1 = time.clock()
coupl.setParareal(pr)
pr.initialize(y1d_init)
pr.iterate()
y1d_pr = pr.state_mic
end_time_1 = time.clock()

Can someone help me to get rid of this error?

machine yearning
  • 9,889
  • 5
  • 38
  • 51
Mian
  • 43
  • 1
  • 4
  • 1
    Please note that `time.clock()` measures wall clock time, and not CPU time. – Mathias711 Apr 26 '16 at 08:00
  • Can you please let me know what to use in Window for CPU time measuring? – Mian Apr 26 '16 at 15:03
  • I looked for it before, but it isn't possible I suppose in python 2.7. Also read the answer [here](http://stackoverflow.com/questions/15176619/timing-the-cpu-time-of-a-python-program) or ask a new question :) – Mathias711 Apr 26 '16 at 15:05

2 Answers2

10

Probably you created a numpy array named time somewhere before this code snippet. You should not do that, because the module time now gets overwritten. Rename your array (to something like time_list), and it works.

Mathias711
  • 6,568
  • 4
  • 41
  • 58
1

I have similar question like this. The error occurs as below

'numpy.ndarray' object has no attribute 'asctime'

That means you have created an array named 'time', so in order to avoid the conficts between Keywords and Variables etc.We have to identify every variable's name and be cautious when import xx as xx

J.Gu
  • 31
  • 6