我想运行命令:
$ cd which automator
Run Code Online (Sandbox Code Playgroud)
以便将 which automator 返回的值传递给 cd。我查遍了所有内容,但找不到简单的答案。救救我吧!
我有以下C代码.在我的机器上,我在大约13秒内计时.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void) {
clock_t begin = clock();
double d = 0;
for (int i = 0; i < 1e9; i++) {
d = 1 + rand() * 5 > 10 ? 4 : rand();
}
clock_t end = clock();
double time_spent = (double) (end - begin) / CLOCKS_PER_SEC;
printf("%f", time_spent);
return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)
但是这个numpy操作,我只需要几分之一秒!
a = np.random.randn(1000, 1000)
b = np.random.randn(1000, 1000)
c = a.dot(b)
Run Code Online (Sandbox Code Playgroud)
这是如何可能的,因为他们正在做相同数量(1e9操作)的工作?numpy并行化?