我的问题类似于,但我正在寻找关于如何处理这个问题的最新信息:
Python
在Linux上运行
在拥有比核心多的线程的CPU上。
例如,假设CPU具有4个核心和8个线程,并给出了以下代码:
from multiprocessing.dummy import Pool as ThreadPool
from multiprocessing import Pool as ProcessPool
with ThreadPool(number_of_threads) as pool:
pool.map(some_function, some_iterable)
with
我有一个非常cpu密集型的玩具web应用程序。
func PerfServiceHandler(w http.ResponseWriter, req *http.Request)
{
start := time.Now()
w.Header().Set("Content-Type", "application/json")
x := 0
for i := 0; i < 200000000; i++ {
x = x + 1
x = x - 1
}
elapsed := time.Sinc