mmapped file slightly faster
This commit is contained in:
parent
eb2ed15e33
commit
5bb2363eee
@ -36,14 +36,20 @@ end
|
|||||||
function main()
|
function main()
|
||||||
open("../../../measurements.txt", "r") do f
|
open("../../../measurements.txt", "r") do f
|
||||||
println("Start")
|
println("Start")
|
||||||
|
sz = Base.stat(f).size
|
||||||
|
data = mmap(f, Vector{UInt8}, sz)
|
||||||
|
idxs = findall(isequal(0x0a), data)
|
||||||
stations = Dict{String,StationMeasurements}()
|
stations = Dict{String,StationMeasurements}()
|
||||||
iteration = 0
|
iteration = 0
|
||||||
for line in eachline(f)
|
last_idx = 1
|
||||||
|
for i in eachindex(idxs)
|
||||||
if iteration % 1000000 == 0 && iteration > 0
|
if iteration % 1000000 == 0 && iteration > 0
|
||||||
print("\x1b[J\x1b[H")
|
print("\x1b[J\x1b[H")
|
||||||
percent = round((iteration / 1000000000) * 100; digits=2)
|
percent = round((iteration / 1000000000) * 100; digits=2)
|
||||||
println("$(percent)%")
|
println("$(percent)%")
|
||||||
end
|
end
|
||||||
|
line = String(data[last_idx:idxs[i]-1])
|
||||||
|
last_idx = idxs[i] + 1
|
||||||
station, temp_str = rsplit(line, ";")
|
station, temp_str = rsplit(line, ";")
|
||||||
temp = parse(Float32, temp_str)
|
temp = parse(Float32, temp_str)
|
||||||
if haskey(stations, station)
|
if haskey(stations, station)
|
||||||
|
Loading…
Reference in New Issue
Block a user