Linux v.s上的基准cp + git Windows:为何如此差异?

时间:2016-04-28 18:55:36

标签: linux windows git performance benchmarking

我使用这个Python script创建了大量文件,主要用于对Git进行基准测试。

结果非常令人惊讶,尤其是Windows和Linux之间的差异。

基本上我的脚本会创建12个目录,每个目录中包含512个文件。每个文件大约2到4 kB。使用Git对象,存储库大约是12k个文件。

我做了基准测试:

  1. 是时候将所有文件添加到git git add .
  2. 结帐前一个分支的时间
  3. 在同一个SSD上复制存储库的时间
  4. 将存储库复制到外部Sata HDD(NTFS)的时间
  5. 我使用Windows 10和Linux上的相同存储库执行此操作:

     Operation               Linux     Windows    Ratio
     ---------               -----     -------    -----
     1. git add .            0.47s      21.7s      x46
     2. git checkout HEAD~1  0.35s      16.2s      x46 
     3. git checkout .       0.40s      20.5s      x50
     4. cp -r ssd->ssd       0.35s      1m14s      x211
     5. cp -r ssd->hdd       4.90s      6m25s      x78 
    

    操作按此顺序完成:

    $ mkdir test
    $ cp test.py test && cd test
    $ ./test.py # Creation of the files
    $ git init
    $ time git add .               # (1)
    $ git commit -qam 1
    $ ./test.py # Alter some files
    $ commit -qam 2
    
    $ cd ..
    $ time cp -r test /media/hdd/  # (4)
    $ time cp -r test test2        # (5)
    $ cd test
    
    $ time git checkout HEAD~1     # (2)
    $ ./test.py 
    $ git checkout master
    $ git reset --soft head~1
    $ time git checkout .          # (3)
    

    基准测试是在同一台PC上完成的(使用双启动)。

    为什么会有这样的差异?我无法相信。

0 个答案:

没有答案