Hi @Jack Huser,
I assume you would agree it is fair to compare apples to apples
but not horse coaches to formula-1 cars.
Being proud that I never lost a benchmark by speed I rewrote your code
that is nice to read and maintain but not very efficient, going for something
more speedy to show the limits and then checked it against your class.
My test file has only 47MB containing 181566 lines.
DEMO>write ##class(JUH.Test).ReadFile(file)
execution: 214.931024
1
DEMO>write ##class(JUH.Test).ReadQuick(file)
execution: .753696
lines: 181566
1
DEMO>write .753696/214.931024*100_" %"
.3506687801385062028 %I think 0.35% is quite an eye catcher.
And his is the class:
ClassMethod ReadQuick(strINReadFile As %String = "") As %Status
{
open strINReadFile::1
else write "Missing File",! quit '$$$OK
set eof=##class(%SYSTEM.Process).SetZEOF(1)
use strINReadFile
set time1=$zh
for line=0:1 {
read strBuffer if $zeof set diff=$zh-time1 quit
// do something with strBuffer
}
close strINReadFile
do ##class(%SYSTEM.Process).SetZEOF(eof)
write !,"execution: "_diff,!,"lines: ",line,!
quit $$$OK
}I just couldn't resist my nature.
- Log in to post comments
.png)