I am using a macbook m1, and when I use the native wc -l $file
I get results lightning fast, almost certainly because I can directly pass in the file. However, I don't see how I can do this with powershell and I am forced to funnel data to stdout
which, even for wc
is slow (but still faster than Measure-Object
Is there a faster way in powershell to get the number of lines in a file? Like wc -l $file
fast?
PS /Users/cbongior/dev/oracle/dart-ingestion/omc> Measure-Command {Get-Content ./final_class2.csv | Measure-Object -Line}
Days : 0
Hours : 0
Minutes : 1
Seconds : 8
Milliseconds : 684
Ticks : 686847045
TotalDays : 0.000794961857638889
TotalHours : 0.0190790845833333
TotalMinutes : 1.144745075
TotalSeconds : 68.6847045
TotalMilliseconds : 68684.7045
PS /Users/cbongior/dev/oracle/dart-ingestion/omc> Measure-Command { wc -l ./final_class2.csv }
Days : 0
Hours : 0
Minutes : 0
Seconds : 0
Milliseconds : 166
Ticks : 1663259
TotalDays : 1.92506828703704E-06
TotalHours : 4.62016388888889E-05
TotalMinutes : 0.00277209833333333
TotalSeconds : 0.1663259
TotalMilliseconds : 166.3259
PS /Users/cbongior/dev/oracle/dart-ingestion/omc> Measure-Command { cat ./final_class2.csv | wc -l }
Days : 0
Hours : 0
Minutes : 0
Seconds : 51
Milliseconds : 187
Ticks : 511870216
TotalDays : 0.00059244237962963
TotalHours : 0.0142186171111111
TotalMinutes : 0.853117026666667
TotalSeconds : 51.1870216
TotalMilliseconds : 51187.0216