powershell - Get Unique records from large files quickly
问题描述
I have big files (at least 20 MB each) where i need to look for string M(\d{10})
Below is the script I am using:
Get-Content -Path Test.log | %{ [Regex]::Matches($_, "M(\d{10})") } | %{ $_.Value } | select -Unique
This is taking good time and more CPU, please suggest how to get the results with lower CPU usage/quicker.
解决方案
只需测量自己(以尽量减少缓存效果差异,第一个重复):
Measure-Command {Get-Content -Path Test.log | %{ [Regex]::Matches($_, "M(\d{10})") } | %{ $_.Value } | select -Unique}
Measure-Command {Get-Content -Path Test.log | %{ [Regex]::Matches($_, "M(\d{10})") } | %{ $_.Value } | select -Unique}
Measure-Command {sls -Path Test.log "M(\d{10})" | %{ $_.Matches.Groups[1].Value } | select -Unique}
推荐阅读
- flutter - 我可以在颤振仪表板中将图标更改为图像或表情符号吗
- python-3.x - 动态规划原始计算器代码优化
- angular - 根据输入在Angular中重新绘制画布线
- android - RecyclerView 滑动删除仍然显示不完整滑动的可绘制
- ip - Google Cloud SQL 上的几个查询
- node.js - 检查电子邮件是否已存在于带有异步和等待的 Mongo Atlas DB 中
- java - 如何将浮动比例转换为长比例?
- python-3.x - 为什么它在结果中显示这个(列表索引超出范围)?
- ios - Xocde - 错误 ITMS-90683 在 Info.plist 文件中缺少目的字符串
- javascript - 达到最大长度值后关注下一个输入 - reactjs