【发布时间】:2017-04-11 02:51:39
【问题描述】:
谁能帮助加快搜索速度?使用此代码,搜索需要几天时间。
Search_Names.csv(大约 10k 个名字)
Need_This_Long_Strings.csv(大约 180k 个字符串,大小为 50MB)
$TimeStamp = Get-Date -Format {yyyy.MM.dd_hh.mm.ss}
$SearchNames = gc D:\Search_Names.csv
$WhereSearch = gc D:\Need_This_Long_Strings.csv
$Val = 0
foreach ($SearchName in $SearchNames)
{
$WhereSearch | Where{$_ | Select-String -Pattern "$SearchName.*"} | Out-File D:\Find_in_Search_File_$TimeStamp.log -Append
$Val = $Val + 1
}
"Count of matches - $Val" |Out-File D:\Find_in_Search_File_$TimeStamp.log -Append
【问题讨论】:
标签: performance search select-string fastercsv boost-foreach