我在Ubuntu上运行一个脚本,并测试它的时间:
$ time ./merger
./merger 0.02s user 0.03s system 99% cpu 0.050 total
Run Code Online (Sandbox Code Playgroud)
它花了不到1秒钟.但如果我使用cygwin:
$ time ./merger
real 3m22.407s
user 0m0.367s
sys 0m0.354s
Run Code Online (Sandbox Code Playgroud)
它花了超过3分钟.为什么会这样?我该怎么做才能提高cygwin的执行速度?
正如其他人已经提到的,Cygwin在 Windows 上实现分叉和进程生成通常很慢。
使用这个 fork() 基准测试,我得到以下结果:
rr-@cygwin:~$ ./test 1000
Forked, executed and destroyed 1000 processes in 5.660011 seconds.
rr-@arch:~$ ./test 1000
Forked, executed and destroyed 1000 processes in 0.142595 seconds.
rr-@debian:~$ ./test 1000
Forked, executed and destroyed 1000 processes in 1.141982 seconds.
Run Code Online (Sandbox Code Playgroud)
使用time (for i in {1..10000};do cat /dev/null;done)基准流程生成性能,我得到以下结果:
rr-@work:~$ time (for i in {1..10000};do cat /dev/null;done)
(...) 19.11s user 38.13s system 87% cpu 1:05.48 total
rr-@arch:~$ time (for i in {1..10000};do cat /dev/null;done)
(...) 0.06s user 0.56s system 18% cpu 3.407 total
rr-@debian:~$ time (for i in {1..10000};do cat /dev/null;done)
(...) 0.51s user 4.98s system 21% cpu 25.354 total
Run Code Online (Sandbox Code Playgroud)
硬件规格:
Intel(R) Core(TM) i7-3770K CPU @ 3.50GHzIntel(R) Core(TM) i7-4790K CPU @ 4.00GHzIntel(R) Core(TM)2 Duo CPU T5270 @ 1.40GHz所以正如你所看到的,无论你使用什么,Cygwin 总是会运行得更差。即使是更糟糕的硬件,它也会轻易失败(根据此比较,与此基准测试相比cygwin)。debian
| 归档时间: |
|
| 查看次数: |
6847 次 |
| 最近记录: |