Skip to content

Instantly share code, notes, and snippets.

@hectorcorrea
Created August 11, 2021 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hectorcorrea/b2509087d6905c0b076f7f457c313870 to your computer and use it in GitHub Desktop.
Save hectorcorrea/b2509087d6905c0b076f7f457c313870 to your computer and use it in GitHub Desktop.
# Parses timing information for lines that include "ELAPSED: "
def parse_file(filename, server)
File.readlines(filename).each do |line|
elapsed = line.index("ELAPSED: ")
next if elapsed.nil?
elapsed += 9
# Line looks like:
# I, [2021-07-10T00:49:28.827383 #9379] INFO -- : ELAPSED: All items for 99106284923506421 took 1429 ms
timestamp = line.split(" ")[1][1..-1]
api = line[elapsed..-1].split(" ")[0..1].join("_").downcase
time = line.match(/took (\d*) ms/)[1].to_i
bibs_count = (api == "find_bibs") ? line.split(",").count : 0
extra = line[elapsed..-1]
puts "#{timestamp}\t#{server}\t#{api}\t#{time}\t#{bibs_count}\t#{extra}"
end
end
puts "TIMESTAMP\tSERVER\tAPI\tTIME\tBIB_COUNT\tEXTRA"
parse_file("bibdata1_elapsed.log", "bibdata-alma1")
parse_file("bibdata2_elapsed.log", "bibdata-alma2")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment