使用Python 2.7.6在Ubuntu 14上运行它
我简化了脚本以显示我的问题:
import time
import multiprocessing
data = range(1, 3)
start_time = time.clock()
def lol():
for i in data:
print time.clock() - start_time, "lol seconds"
def worker(n):
print time.clock() - start_time, "multiprocesor seconds"
def mp_handler():
p = multiprocessing.Pool(1)
p.map(worker, data)
if __name__ == '__main__':
lol()
mp_handler()
Run Code Online (Sandbox Code Playgroud)
并输出:
8e-06 lol seconds
6.9e-05 lol seconds
-0.030019 multiprocesor seconds
-0.029907 multiprocesor seconds
Process finished with exit code 0
Run Code Online (Sandbox Code Playgroud)
使用 time.time()给出非负值(如此处标记的Timer显示负时间已过)但我很好奇time.clock()python中的问题multiprocessing和从CPU读取时间.
我试图明确地找出 SciPy/NumPy 中的哪些函数在多个处理器上运行。例如,我可以在 SciPy 参考手册中读到 SciPy 使用它,但我对哪些函数确实运行并行计算更感兴趣,因为并非所有函数都这样做。理想的场景当然是在您键入 help(SciPy.foo) 时包含它,但情况似乎并非如此。
任何帮助都感激不尽。
最好的事物,
马蒂亚斯
我试图将具有相关纬度和经度的不规则网格化数据集(原始卫星数据)映射到由给定的经常网格化的纬度和经度集basemap.makegrid().我使用matplotlib.mlab.griddata与mpl_toolkits.natgrid安装.下面是whosipython中用作输出的变量列表以及变量的一些统计信息:
Variable Type Data/Info
-------------------------------
datalat ndarray 666x1081: 719946 elems, type `float32`, 2879784 bytes (2 Mb)
datalon ndarray 666x1081: 719946 elems, type `float32`, 2879784 bytes (2 Mb)
gridlat ndarray 1200x1000: 1200000 elems, type `float64`, 9600000 bytes (9 Mb)
gridlon ndarray 1200x1000: 1200000 elems, type `float64`, 9600000 bytes (9 Mb)
var ndarray 666x1081: 719946 elems, type `float32`, 2879784 bytes (2 Mb)
In [11]: var.min()
Out[11]: -30.0
In [12]: var.max()
Out[12]: 30.0
In [13]: …Run Code Online (Sandbox Code Playgroud)