有效计数目录中的文件和子文件夹的具体名称

问题描述 投票:3回答:6

我可以指望一个文件夹和子文件夹中的所有文件,文件夹本身不计算在内。

(gci -Path *Fill_in_path_here* -Recurse -File | where Name -like "*STB*").Count

然而,PowerShell是用于文件(最多700K)的量太慢。我读了cmd是在执行这种任务的速度更快。

不幸的是我没有的CMD代码的知识都没有。在上面的例子中我指望的所有文件,在文件名STB

这就是我想在cmd中做的一样好东西。

任何帮助表示赞赏。

performance powershell cmd
6个回答
2
投票

基于直接使用.NET(Theo's helpful answer)的[System.IO.Directory]::EnumerateFiles()是最快的选项(在我的测试,情况因人而异 - 请参阅下面的基准码[1])。

其上的Windows PowerShell是 - - 它在.NET Framework(FullCLR)限制是:

  • 当遇到无法访问的目录(由于缺乏权限),则会引发异常。您可以捕获该异常,但你不能继续枚举;也就是说,你不能有力枚举,你可以同时忽略那些你不能访问的所有项目。
  • 隐藏的项目都不约而同地包括在内。
  • 递归枚举,符号链接/路口目录都不约而同地紧随其后。

相比之下,跨平台.NET核心框架,因为V2.1 - 上PowerShell核心是建立 - 提供解决这些限制的方式,通过EnumerationOptions选项 - 见this answer为例。

请注意,您还可以通过相关[System.IO.DirectoryInfo]类型,它们执行枚举 - 类似Get-ChildItem - 返回丰富的对象,而不是单纯的路径字符串,允许多的多才多艺的处理;例如,要获得所有文件大小的阵列(属性.Length,隐式地应用到每个文件对象):

([System.IO.DirectoryInfo] $somePath).EnumerateFiles('*STB*', 'AllDirectories').Length

这解决了这些限制,仍然是相当快的原生PowerShell的解决方案是与Get-ChildItem参数使用-Filter

(Get-ChildItem -LiteralPath $somePath -Filter *STB* -Recurse -File).Count
  • 隐藏的项目默认情况下排除在外;添加-Force包括他们。
  • 要忽略权限问题,添加-ErrorAction SilentlyContinue-ErrorAction Ignore; SilentlyContinue的好处是,你可以在以后检查$Error集合来确定发生的特定错误,以保证误差只有真正从权限问题造成的。 需要注意的是PowerShell核心 - 不像Windows PowerShell中 - 有益忽略无法枚举hidden system junctions that exist for pre-Vista compatibility only的内容,如$env:USERPROFILE\Cookies
  • 在Windows PowerShell中,Get-ChildItem -Recurse总是遵循符号链接/路口目录,不幸;更理智,PowerShell核心默认情况下没有,并提供选入通过-FollowSymlink
  • 像基于[System.IO.DirectoryInfo]的解决方案,Get-ChildItem输出丰富的对象([System.IO.FileInfo] / [System.IO.DirectoryInfo])描述每个列举的文件系统项,允许通用的处理。

请注意,虽然也可以通过通配符参数-Path(隐含的第一位置参数)和-Include(如在TobyU's answer),它是唯一的,它提供显著速度的改进,由于在源极(文件系统驱动程序)过滤-Filter,使得PowerShell中只接收已过滤的结果;相比之下,-Path / -Include必须首先列举对事后通配符模式一切和相匹配。[2]

注意事项重新-Filter使用:

  • 它的通配符的语言是不一样的PowerShell的;值得注意的是,它不支持字符集/范围(例如*[0-9]),它具有遗留怪癖 - 见this answer
  • 它仅支持单个通配符模式,而-Include支持多个(如阵列)。

这就是说,-Filter过程通配符方式cmd.exedir相同。


最后,完整性,可以适应MC ND's helpful answer的基础上在PowerShell中,使用cmd.exedir命令着想从而简化事项:

(cmd /c dir /s /b /a-d "$somePath/*STB*").Count

PowerShell中捕获一个外部程序的stdout输出作为线的阵列,其元素计数可以简单地与.Count(或.Length)属性查询。

这就是说,这可能会或可能不会比PowerShell的自己Get-ChildItem -Filter更快,这取决于过滤方案;还要注意dir /s永远只能返回路径字符串,而Get-ChildItem返回丰富的对象,其属性就可以查询。

注意事项重新dir使用:

  • /a-d排除目录,即只报告文件,但后来也包括隐藏文件,这dir默认情况下不会做的。
  • dir /s不约而同地降入过在递归枚举隐藏目录;一个/a(基于属性的)过滤器仅适用于枚举的叶项(仅在这种情况下的文件)。
  • dir /s总是如下符号链接/结到其他目录(假设它具有所需的权限 - 见下点)。
  • dir /s悄悄忽略的目录或符号链接/路口的目录,如果它不能枚举其内容由于缺乏权限 - 而这是在上述系统隐藏路口的具体情况有帮助的(你可以找到他们所有cmd /c dir C:\ /s /ashl),它可以使你错过那你想列举目录的内容,但不能真正缺少权限,因为dir /s会给任何迹象表明,这些内容甚至可能存在(如果直接目标无法访问的目录,你会得到一个有点误导File Not Found错误消息,并且退出代码被设置为1)。

性能对比:

  • 下面的测试比较纯枚举性能而不进行过滤,为简单起见,假定使用一个相当大的目录树,存在于所有的系统,c:\windows\winsxs;这么说,这很容易适应测试也比较滤波性能。
  • 该测试是从PowerShell的,这意味着一些开销是为了调用cmd.exe创建子进程dir /s,虽然(a)该开销应该是比较低的,并介绍运行(二)较大的一点是,留在境界的PowerShell是值得的,相比cmd.exe给予其大大优于功能。
  • 测试使用功能Time-Command,可以从this Gist下载,默认情况下平均为10次。
# Warm up the filesystem cache for the target dir.,
# both from PowerShell and cmd.exe, to be safe.
gci 'c:\windows\winsxs' -rec >$null; cmd /c dir /s 'c:\windows\winsxs' >$null

Time-Command `
  { @([System.IO.Directory]::EnumerateFiles('c:\windows\winsxs', '*', 'AllDirectories')).Count },
  { (Get-ChildItem -Force -Recurse -File 'c:\windows\winsxs').Count },
  { (cmd /c dir /s /b /a-d 'c:\windows\winsxs').Count },
  { cmd /c 'dir /s /b /a-d c:\windows\winsxs | find /c /v """"' }

在我的单核VMware Fusion的虚拟机上的Microsoft Windows 10专业版的Windows PowerShell v5.1.17134.407(64位; 1803版本,OS版本号:17134.523)我得到以下计时,从最快到最慢(滚动到右侧看到Factor栏,显示相对表现):

Command                                                                                    Secs (10-run avg.) TimeSpan         Factor
-------                                                                                    ------------------ --------         ------
@([System.IO.Directory]::EnumerateFiles('c:\windows\winsxs', '*', 'AllDirectories')).Count 11.016             00:00:11.0158660 1.00
(cmd /c dir /s /b /a-d 'c:\windows\winsxs').Count                                          15.128             00:00:15.1277635 1.37
cmd /c 'dir /s /b /a-d c:\windows\winsxs | find /c /v """"'                                16.334             00:00:16.3343607 1.48
(Get-ChildItem -Force -Recurse -File 'c:\windows\winsxs').Count                            24.525             00:00:24.5254979 2.23

有趣的是,[System.IO.Directory]::EnumerateFiles()Get-ChildItem溶液是显著快于PowerShell核心,其在.NET核心之上运行(如PowerShell核心6.2.0-preview.4的,.NET核心2.1):

Command                                                                                    Secs (10-run avg.) TimeSpan         Factor
-------                                                                                    ------------------ --------         ------
@([System.IO.Directory]::EnumerateFiles('c:\windows\winsxs', '*', 'AllDirectories')).Count 5.094              00:00:05.0940364 1.00
(cmd /c dir /s /b /a-d 'c:\windows\winsxs').Count                                          12.961             00:00:12.9613440 2.54
cmd /c 'dir /s /b /a-d c:\windows\winsxs | find /c /v """"'                                14.999             00:00:14.9992965 2.94
(Get-ChildItem -Force -Recurse -File 'c:\windows\winsxs').Count                            16.736             00:00:16.7357536 3.29

[1] [System.IO.Directory]::EnumerateFiles()固有和无疑比Get-ChildItem溶液更快。在我的测试(请参见“性能比较:”以上),[System.IO.Directory]::EnumerateFiles()击败了cmd /c dir /s为好,稍在Windows PowerShell中,并明确因此在PowerShell核心,但others report different findings。这就是说,发现整体最快的解决方案是不是唯一的考虑,特别是如果不只是计数的文件更多的是需要,如果枚举需要是稳健的。这个答案讨论了各种方案的优缺点。

[2]实际上,由于低效的实现作为的Windows PowerShell V5.1的/ PowerShell核心6.2.0-preview.4,使用-Path-Include的实际上是比使用未过滤Get-ChildItem,而是使用具有... | Where-Object Name -like *STB*一个额外的流水线段慢,如OP - 见this GitHub issue


3
投票

其中一个最快捷的方法来做到这一点在cmd命令行或批处理文件可能是

dir "x:\some\where\*stb*" /s /b /a-d | find /c /v ""

只是一个递归(/sdir命令列出裸格式的所有文件(没有文件夹/a-d)(/b),所有的输出管道输送到find命令,将数(/c)的非空行(/v "")的数量

但是,在任何情况下,你需要枚举文件,它需要时间。

编辑以适应评论,但

注意下面的方法,因为,至少在Windows 10,在dir命令的汇总行的空间填充设置为五个位置不适合这种情况下工作。文件计数大于99999没有正确填充,所以sort /r输出是不正确的。

正如指出的本Personick的dir命令还输出文件的数量,我们可以检索此信息:

@echo off
    setlocal enableextensions disabledelayedexpansion

    rem Configure where and what to search
    set "search=x:\some\where\*stb*"

    rem Retrieve the number of files
    set "numFiles=0"
    for /f %%a in ('
        dir "%search%" /s /a-d /w 2^>nul        %= get the list of the files        =%
        ^| findstr /r /c:"^  *[1-9]"            %= retrieve only summary lines      =%
        ^| sort /r 2^>nul                       %= reverse sort, greater line first =%
        ^| cmd /e /v /c"set /p .=&&echo(!.!"    %= retrieve only first line         =%
    ') do set "numFiles=%%a"

    echo File(s) found: %numFiles% 

其基本思想是使用管道命令的系列处理的数据检索的不同部分:

  • 使用dir命令生成的文件列表(/w包括刚刚产生更少的线)。
  • 因为我们只希望与找到的文件的数量汇总行,findstr用于只检索开始线与空间(页眉/汇总行)和一个数字大于0(文件计数摘要行,因为我们使用/a-d目录计数摘要线将具有值0)。
  • 排序以相反的顺序,结束与更大的线的第一线(摘要行开始是左空间填充数)。大线(最终的文件数或同等学历)将是第一道防线。
  • 在一个单独的set /p例如使用cmd命令只检索这条线。由于全序列被包裹在一个for /f和检索从命令执行长列表时,它具有性能问题,我们会尝试恢复尽可能少。

for /f将令牌化的检索线,拿到第一个标记(文件数),并设置用于保存数据的变量(变量已经初始化,有可能是没有文件可以找到)。


2
投票

您可以加快事情的PowerShell,如果直接包括filter而不是过滤比过滤一个预先的方式更大的命令的commandresult set

尝试这个:

(Get-ChildItem -Path "Fill_in_path_here" -Recurse -File -Include "*STB*").Count

1
投票

我的猜测是,这是快了很多:

$path = 'Fill_in_path_here'
@([System.IO.Directory]::EnumerateFiles($path, '*STB*', 'AllDirectories')).Count

如果你不想递归子文件夹,更改'AllDirectories''TopDirectoryOnly'


1
投票

我宁愿做PowerShell的,因为它是一个更强有力的工具。你可能把这个.bat文件脚本一试。

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION

SET /A "N=0"
FOR /F "delims=" %%f IN ('DIR /S /B /A:-D "C:\path\to\files\*STB*"') DO (SET /A "N=!N!+1")
ECHO There are !N! files.

-1
投票

General testing favors MCND's command when run against several systems

Results over 1000 Runs:

摘要


P/VM -          OS - PS Ver -  Files - Winner - Faster By % Seconds - Winner FPS - Loser FPS (Files Per Second)
---- - ----------- - ------ - ------ - ------ - ------------------- - ---------- - ----------------------------
 PM  - Win    7    - 5.1.1  -  87894 - SysIO  - 9%  (0.29s)         - 27,237 FPS - 24,970 FPS
 PM  - Win 2012    - 5.1.1  - 114968 - MCND   - 8%  (0.38s)         - 25,142 FPS - 23,226 FPS
 VM  - Win 2012    - 5.1.1  -  99312 - MCND   - 34% (1.57s)         - 21,265 FPS - 15,890 FPS
 PM  - Win 2016    - 5.1.1  - 102812 - SysIO  - 2%  (0.12s)         - 20,142 FPS - 19,658 FPS
 VM  - Win 2012 R2 -  4.0   -  98396 - MCND   - 29-34% (1.56-1.71s) - 19,787 FPS - 14,717 FPS
 PM  - Win 2008 R2 - 5.0.1  -  46557 - MCND   - 13-17% (0.33-0.44s) - 18,926 FPS - 16,088 FPS
 VM  - Win 2012 R2 -  4.0   -  90906 - MCND   - 22% (1.25s)         - 16,772 FPS - 13,629 FPS

Additionally Theos command will bomb on C:\Windows while MCND's works as expected.

- 我在评论解释MK的\饼干目录等这样的目录是故意不穿越,让你不OD重复计算包含在其中的文件。

MK跑在VMware Fusion的运行顶上他的MAC OS测试还远远没有定论,并显示出执行时间并立即放倒我了,他们奇怪的结果令人难以置信的慢。

另外,我无法执行的写MK命令并接收该文件夹中的文件数的结果,所以我已经包含在我的测试片段,显示用做给正确的结果的所有方法。

Here is the code used for my runs, note I also ran 1000 runs using MK's preferred method to compare output.

奇怪的是,对于MCND命令一个.Count之间的方法似乎给我的win7系统上非常偏颇的结果,从任何其他系统在初始运行我张贴非常不同和巨大较慢(5倍速度较慢),并改变最对未来的运行我试过。

但我认为,这是由于负载,并计划放弃这些成果如果我懒得发布更多,但其余大部分系统都是非常相似的结果我觉得,如果他们没有很大的不同,他们可能似乎是多余的系统。

$MaxRuns=1000
$Root_Dir="c:\windows\winsxs"
$Results_SysIO=@()
$Results_MCND1=@()
$Results_MCND2=@()
$Results_MCND3=@()
$Results_Meta=@()

FOR ($j=1; $j -le $MaxRuns; $j++) {

      Write-Progress -Activity "Testing Mthods for $MaxRuns Runs" -Status "Progress: $($j/$MaxRuns*100)% -- Run $j of $MaxRuns" -PercentComplete ($j/$MaxRuns*100) 

    # Tests  SysIO: @([System.IO.Directory]::EnumerateFiles($Root_Dir, '*', 'AllDirectories')).Count
      $Results_SysIO+=Measure-Command { @([System.IO.Directory]::EnumerateFiles($Root_Dir, '*', 'AllDirectories')).Count }
      sleep -milliseconds 500

    # Tests  MCND1 CMD Script:  DIR "%~1" /s /a-d ^| FIND /I /V "" | find /c /v ""
      $Results_MCND1+=Measure-Command {C:\Admin\TestMCNDFindFiles1.cmd $Root_Dir}
      sleep -milliseconds 500

     # Tests MCND2 CMD Count: {cmd /c 'dir /s /b /a-d $Root_Dir | find /c /v """"'}
      $Results_MCND2+=Measure-Command {cmd /c `"dir /s /b /a-d $Root_Dir `| find /c /v `"`"`"`"`"}
      sleep -milliseconds 500

     # Tests MCND3 PS Count (cmd /c dir /s /b /a-d $Root_Dir).Count
      $Results_MCND3+=Measure-Command {(cmd /c dir /s /b /a-d $Root_Dir).Count}
      sleep -milliseconds 500


}

$CPU=Get-WmiObject Win32_Processor
""
"CPU: $($($CPU.name).count)x $($CPU.name | select -first 1) - Windows: $($(Get-WmiObject Win32_OperatingSystem).Version) - PS Version: $($PSVersionTable.PSVersion)"
ForEach ($Name in "SysIO","MCND1","MCND2","MCND3") {
    $Results_Meta+=[PSCustomObject]@{
      Method=$Name
      Min=$($($(Get-Variable -Name "Results_$Name" -valueOnly).TotalSeconds|Measure-Object -Minimum).Minimum)
      Max=$($($(Get-Variable -Name "Results_$Name" -valueOnly).TotalSeconds|Measure-Object -Maximum).Maximum)
      Avg=$($($(Get-Variable -Name "Results_$Name" -valueOnly).TotalSeconds|Measure-Object -Average).Average)
    }
}

$Results_Meta | sort Avg | select Method,Min,Max,Avg,@{N="Factor";e={("{0:f2}" -f (([math]::Round($_.Avg / $($Results_Meta | sort Avg | select Avg)[0].avg,2,1))))}}|FT

Time-Command `
{cmd /c `"dir /s /b /a-d $Root_Dir `| find /c /v `"`"`"`"`"},
{C:\Admin\TestMCNDFindFiles1.cmd $Root_Dir},
{@([System.IO.Directory]::EnumerateFiles($Root_Dir, '*', 'AllDirectories')).Count},
{(cmd /c dir /s /b /a-d $Root_Dir).Count} $MaxRuns `

""
"Results of Commands - (How many Files were in that Folder?):"

[PSCustomObject]@{
    SysIO=$(&{ @([System.IO.Directory]::EnumerateFiles($Root_Dir, '*', 'AllDirectories')).Count })
    MCND1=$(&{C:\Admin\TestMCNDFindFiles1.cmd $Root_Dir})
    MCND2=$(&{cmd /c `"dir /s /b /a-d $Root_Dir `| find /c /v `"`"`"`"`"})
    MCND3=$(&{(cmd /c dir /s /b /a-d $Root_Dir).Count})
}

我有另外的奔跑我也没有从其他系统收集,Win7的结果不一致,但这样我可能会带他们时,我有更多的增加来自其他系统的列表。

详细的调查结果


物理Win 7的笔记本电脑 - 87894页的文件 - 失败者:MCND为9%(.29s)慢 - (制胜方法:27237 FPS) - 结果是不是重播一致的,而其他的系统。

CPU:1个英特尔(R)酷睿(TM)i5-4310U CPU @ 2.00GHz - 视窗:6.1.7601 - PS版本:5.1.14409.1012


CPU: 1x Intel(R) Core(TM) i5-4310U CPU @ 2.00GHz - Windows: 6.1.7601 - PS Version: 5.1.14409.1012

Method       Min       Max          Avg Factor
------       ---       ---          --- ------
SysIO  3.0190345 6.1287085 3.2174689013 1.00  
MCND1  3.3655209 5.9024033 3.5490564665 1.10  
MCND3  3.5865989 7.5816207 3.8515160528 1.20  
MCND2  3.7542295 7.5619913 3.9471552743 1.23  
3.2174689013
0.0000366062
Command                                                                          Secs (1000-run avg.) TimeSpan         Factor
-------                                                                          -------------------- --------         ------
@([System.IO.Directory]::EnumerateFiles($Root_Dir, '*', 'AllDirectories')).Count 3.227                00:00:03.2271969 1.00  
C:\Admin\TestMCNDFindFiles1.cmd $Root_Dir                                        3.518                00:00:03.5178810 1.09  
cmd /c `"dir /s /b /a-d $Root_Dir `| find /c /v `"`"`"`"`"                       3.911                00:00:03.9106284 1.21  
(cmd /c dir /s /b /a-d $Root_Dir).Count                                          16.338               00:00:16.3377823 5.06  

Results of Commands - (How many Files were in that Folder?):

SysIO MCND1 MCND2 MCND3
----- ----- ----- -----
87894 87894 87894 87894

物理赢2012台式机 - 114968个文件 - 失败者:SYSIO为8%(.38s)慢 - (制胜方法:25142 FPS)

CPU:1个英特尔(R)至强(R)CPU E5-2407 0 @ 2.20GHz - 视窗:6.3.9600 - PS版本:5.1.14409.1012


CPU: 1x Intel(R) Xeon(R) CPU E5-2407 0 @ 2.20GHz - Windows: 6.3.9600 - PS Version: 5.1.14409.1012

Method       Min        Max          Avg Factor
------       ---        ---          --- ------
MCND1  4.4957173  8.6672112 4.5726616326 1.00  
MCND3  4.6815509 18.6689706 4.7940769407 1.05  
SysIO  4.8789948  5.1625618 4.9476786004 1.08  
MCND2  5.0404912  7.2557797 5.0854683543 1.11  

Command                                                                          Secs (1000-run avg.) TimeSpan         Factor
-------                                                                          -------------------- --------         ------
C:\Admin\TestMCNDFindFiles1.cmd $Root_Dir                                        4.542                00:00:04.5418653 1.00  
(cmd /c dir /s /b /a-d $Root_Dir).Count                                          4.772                00:00:04.7719769 1.05  
@([System.IO.Directory]::EnumerateFiles($Root_Dir, '*', 'AllDirectories')).Count 4.933                00:00:04.9330404 1.09  
cmd /c `"dir /s /b /a-d $Root_Dir `| find /c /v `"`"`"`"`"                       5.086                00:00:05.0855891 1.12  

Results of Commands - (How many Files were in that Folder?):

 SysIO MCND1  MCND2   MCND3
 ----- -----  -----   -----
114968 114968 114968 114968

VM赢2012服务器 - 99312页的文件 - 失败者:SYSIO是34%(1.57s)慢 - (制胜方法:21265 FPS)

CPU:4X英特尔(R)至强(R)CPU E7-2850 @ 2.00GHz - 视窗:6.3.9600 - PS版本:5.1.14409.1005


CPU: 4x Intel(R) Xeon(R) CPU E7- 2850  @ 2.00GHz - Windows: 6.3.9600 - PS Version: 5.1.14409.1005

Method       Min       Max              Avg Factor
------       ---       ---              --- ------
MCND1  4.5563908 5.2656374     4.6812307177 1.00  
MCND3  4.6696518 5.3846231     4.9064852835 1.05  
MCND2  5.0559205 5.5583717 5.15425442679999 1.10  
SysIO   6.036294 6.7952711      6.254027334 1.34  

Command                                                                          Secs (1000-run avg.) TimeSpan         Factor
-------                                                                          -------------------- --------         ------
C:\Admin\TestMCNDFindFiles1.cmd $Root_Dir                                        4.669                00:00:04.6689048 1.00  
(cmd /c dir /s /b /a-d $Root_Dir).Count                                          4.934                00:00:04.9336925 1.06  
cmd /c `"dir /s /b /a-d $Root_Dir `| find /c /v `"`"`"`"`"                       5.153                00:00:05.1532386 1.10  
@([System.IO.Directory]::EnumerateFiles($Root_Dir, '*', 'AllDirectories')).Count 6.239                00:00:06.2389727 1.34  

Results of Commands - (How many Files were in that Folder?):

SysIO MCND1 MCND2 MCND3
----- ----- ----- -----
99312 99312 99312 99312

物理赢2016服务器 - 102812个文件 - 失败者:MCND为2%(0.12S)慢 - (制胜方法:20142 FPS)

CPU:2个英特尔(R)至强(R)CPU E5-2667 V4 @ 3.20GHz - 视窗:10.0.14393 - PS版本:5.1.14393.2608


CPU: 2x Intel(R) Xeon(R) CPU E5-2667 v4 @ 3.20GHz - Windows: 10.0.14393 - PS Version: 5.1.14393.2608

Method       Min       Max              Avg Factor
------       ---       ---              --- ------
SysIO  5.0414178 5.5279055     5.1043614001 1.00  
MCND3  5.0468476 5.4673033 5.23160342460001 1.02  
MCND1  5.1649438 5.6745749 5.26664923669999 1.03  
MCND2  5.3280266 5.7989287     5.3747728434 1.05  

Command                                                                          Secs (1000-run avg.) TimeSpan         Factor
-------                                                                          -------------------- --------         ------
@([System.IO.Directory]::EnumerateFiles($Root_Dir, '*', 'AllDirectories')).Count 5.156                00:00:05.1559628 1.00  
(cmd /c dir /s /b /a-d $Root_Dir).Count                                          5.256                00:00:05.2556244 1.02  
C:\Admin\TestMCNDFindFiles1.cmd $Root_Dir                                        5.272                00:00:05.2722298 1.02  
cmd /c `"dir /s /b /a-d $Root_Dir `| find /c /v `"`"`"`"`"                       5.375                00:00:05.3747287 1.04  

Results of Commands - (How many Files were in that Folder?):

 SysIO MCND1  MCND2   MCND3
 ----- -----  -----   -----
102812 102812 102812 102812

VM赢2012 R2服务器 - 98396页的文件 - 失败者:SYSIO 29-34%(1.56-1.71s)慢 - (制胜方法:19,787 FPS)

CPU:2个英特尔(R)至强(R)CPU E7-2850 @ 2.00GHz - 视窗:6.3.9600 - PS版本:4.0


CPU: 2x Intel(R) Xeon(R) CPU E7- 2850  @ 2.00GHz - Windows: 6.3.9600 - PS Version: 4.0


Method                                                        Min                             Max                             Avg Factor                         
------                                                        ---                             ---                             --- ------                         
MCND1                                                   4.7007419                       5.9567352                4.97285509330001 1.00                           
MCND2                                                   5.2086999                       6.7678172                    5.4849721167 1.10                           
MCND3                                                   5.0116501                       8.7416729                5.71391797679999 1.15                           
SysIO                                                   6.2400687                        7.414201                    6.6862204345 1.34 

Command                                  Secs (1000-run avg.)                     TimeSpan                                Factor                                 
-------                                  --------------------                     --------                                ------                                 
C:\Admin\TestMCNDFindFiles1.cmd $Root... 5.359                                    00:00:05.3592304                        1.00                                   
cmd /c `"dir /s /b /a-d $Root_Dir `| ... 5.711                                    00:00:05.7107644                        1.07                                   
(cmd /c dir /s /b /a-d $Root_Dir).Count  6.173                                    00:00:06.1728413                        1.15                                   
@([System.IO.Directory]::EnumerateFil... 6.921                                    00:00:06.9213833                        1.29                                   

Results of Commands - (How many Files were in that Folder?):

                                   SysIO MCND1                                    MCND2                                                                     MCND3
                                    ----- -----                                    -----                                                                     -----
                                   98396 98396                                    98396                                                                     98396

物理赢2008 R2服务器 - 46557页的文件 - 失败者:SYSIO 13-17%(0.33-0.44s)慢 - (制胜方法:18926 FPS)

CPU:2个英特尔(R)至强(R)CPU 5160 @ 3.00GHz - 视窗:6.1.7601 - PS版本:5.0.10586.117


CPU: 2x Intel(R) Xeon(R) CPU            5160  @ 3.00GHz - Windows: 6.1.7601 - PS Version: 5.0.10586.117

Method       Min       Max          Avg Factor
------       ---       ---          --- ------
MCND3  2.2370018 2.8176253 2.4653543378 1.00  
MCND1  2.4063578 2.8108379 2.5373719772 1.03  
MCND2  2.5953631 2.9085969 2.7312907064 1.11  
SysIO  2.7207865 30.335369 2.8940406601 1.17  

Command                                                                          Secs (1000-run avg.) TimeSpan         Factor
-------                                                                          -------------------- --------         ------
(cmd /c dir /s /b /a-d $Root_Dir).Count                                          2.500                00:00:02.5001477 1.00  
C:\Admin\TestMCNDFindFiles1.cmd $Root_Dir                                        2.528                00:00:02.5275259 1.01  
cmd /c `"dir /s /b /a-d $Root_Dir `| find /c /v `"`"`"`"`"                       2.726                00:00:02.7259539 1.09  
@([System.IO.Directory]::EnumerateFiles($Root_Dir, '*', 'AllDirectories')).Count 2.826                00:00:02.8259697 1.13  

Results of Commands - (How many Files were in that Folder?):

SysIO MCND1 MCND2 MCND3
----- ----- ----- -----
46557 46557 46557 46557

VMWare的赢2012 R2服务器 - 90906页的文件 - 失败者:SYSIO 23%(1.25秒)慢 - (制胜方法:15722 FPS)

CPU:4X英特尔(R)至强(R)CPU E7-2850 @ 2.00GHz - 视窗:6.3.9600 - PS版本:4.0


CPU: 4x Intel(R) Xeon(R) CPU E7- 2850  @ 2.00GHz - Windows: 6.3.9600 - PS Version: 4.0

Method                                                        Min                             Max                             Avg Factor                         
------                                                        ---                             ---                             --- ------                         
MCND1                                                   5.0516057                       6.4537866                     5.423386317 1.00                           
MCND3                                                   5.3297157                       7.1722929                    5.9030135773 1.09                           
MCND2                                                   5.5460548                       7.0356455                     5.931334868 1.09                           
SysIO                                                   6.2059999                      19.5145373                    6.6747122712 1.23                           

Command                                  Secs (1000-run avg.)                     TimeSpan                                Factor                                 
-------                                  --------------------                     --------                                ------                                 
C:\Admin\TestMCNDFindFiles1.cmd $Root... 5.409                                    00:00:05.4092046                        1.00                                   
(cmd /c dir /s /b /a-d $Root_Dir).Count  5.936                                    00:00:05.9358832                        1.10                                   
cmd /c `"dir /s /b /a-d $Root_Dir `| ... 6.069                                    00:00:06.0689899                        1.12                                   
@([System.IO.Directory]::EnumerateFil... 6.557                                    00:00:06.5571859                        1.21                                   


Results of Commands - (How many Files were in that Folder?):

                                   SysIO MCND1                                    MCND2                                                                     MCND3
                                    ----- -----                                    -----                                                                     -----
                                   90906 90906                                    90906                                                                     90906

© www.soinside.com 2019 - 2024. All rights reserved.