Skip to content

Conversation

odow
Copy link
Member

@odow odow commented Sep 12, 2025

Another follow-up to #2840

Now reading into an MOI model is only 4x slower than just counting the new lines char-by-char:

julia> import MathOptInterface as MOI

julia> function main()
           model = MOI.FileFormats.LP.Model{Float64}()
           MOI.read_from_file(model, "/Users/odow/Downloads/QPLIB_10005.lp")
           return model
       end
main (generic function with 1 method)

julia> @time main();
  1.065072 seconds (43.71 M allocations: 1.511 GiB, 22.66% gc time)

julia> function count_newlines(io::IO)
           i = 0
           while !eof(io)
               if read(io, Char) == '\n'
                   i += 1
               end
           end
           return i
       end
count_newlines (generic function with 1 method)

julia> @time open(count_newlines, "/Users/odow/Downloads/QPLIB_10005.lp", "r")
  0.274165 seconds (14 allocations: 792 bytes)
201553

@odow odow merged commit 79ff5d0 into master Sep 12, 2025
31 checks passed
@odow odow deleted the od/lp-type-stable branch September 12, 2025 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant