cygwin为什么这么慢 [英] why is cygwin so slow
问题描述
我在Ubuntu上运行了一个脚本,并测试了其时间:
I run a script on Ubuntu, and tested its time:
$ time ./merger
./merger 0.02s user 0.03s system 99% cpu 0.050 total
它花费了不到1秒的时间. 但是如果我使用cygwin:
it spent less than 1 second. but if I used cygwin:
$ time ./merger
real 3m22.407s
user 0m0.367s
sys 0m0.354s
花了3分钟以上. 为什么会这样呢?我该如何提高cygwin的执行速度?
It spent more than 3 minutes. Why did this happen? What shall I do to increase the executing speed on cygwin?
推荐答案
As others have already mentioned, Cygwin's implementation of fork and process spawning on Windows in general are slow.
使用此fork()基准,我得到以下结果:
Using this fork() benchmark, I get following results:
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.
使用time (for i in {1..10000};do cat /dev/null;done)
基准化进程生成性能,得到以下结果:
Using time (for i in {1..10000};do cat /dev/null;done)
to benchmark process spawning performance, I get following results:
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
硬件规格:
- cygwin :
Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz
- 架构:
Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
- debian :
Intel(R) Core(TM)2 Duo CPU T5270 @ 1.40GHz
- cygwin:
Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz
- arch:
Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
- debian:
Intel(R) Core(TM)2 Duo CPU T5270 @ 1.40GHz
因此,如您所见,无论您使用什么,Cygwin始终会性能更差.根据
So as you see, no matter what you use, Cygwin will always operate worse. It loses hands down even to worse hardware (cygwin
vs. debian
in this benchmark, as per this comparison).
这篇关于cygwin为什么这么慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!