bench-parse-perf.lua 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/usr/bin/lua
  2. local pretty_names = {
  3. binarytrees = "Binary Trees",
  4. fannkuch = "Fannkuch",
  5. fasta = "Fasta",
  6. knucleotide = "K-Nucleotide",
  7. mandelbrot = "Mandelbrot",
  8. nbody = "N-Body",
  9. spectralnorm = "Spectral Norm",
  10. }
  11. local function parse_name(module)
  12. local code, is_aot = string.match(module, "^(.*)(_cor)$")
  13. if is_aot then
  14. return code, "aot"
  15. else
  16. return module, "lua"
  17. end
  18. end
  19. local function pretty_name(module)
  20. local code, aot = string.match(module, "^(.*)(_cor)$")
  21. local name = assert(pretty_names[code or module])
  22. if aot then
  23. return name .. " (AOT)"
  24. else
  25. return name .. " (Lua)"
  26. end
  27. end
  28. local rows = {}
  29. while true do
  30. local blank = io.read("l");
  31. if not blank then break end
  32. assert(blank == "")
  33. local lines = {}
  34. for i = 1, 18 do
  35. lines[i] = io.read("l")
  36. end
  37. local module = assert(string.match(lines[1], "stats for .* (%S+) %d+ >"))
  38. local cycle = assert(string.match(lines[7], "(%S+) *cycles"))
  39. local instr = assert(string.match(lines[8], "(%S+) *instructions"))
  40. local ipc = assert(string.match(lines[8], "(%S+) *insn per cycle"))
  41. local time = assert(string.match(lines[12], "(%S+) *seconds time elapsed"))
  42. local r = {}
  43. r.code, r.is_aot = parse_name(module)
  44. r.cycle = tonumber(cycle)
  45. r.instr = tonumber(instr)
  46. r.ipc = tonumber(ipc)
  47. r.time = tonumber(time)
  48. table.insert(rows, r)
  49. end
  50. for i = 1, #rows, 2 do
  51. local lua = rows[i]
  52. local aot = rows[i+1]
  53. assert(lua.code == aot.code)
  54. assert(lua.is_aot == "lua")
  55. assert(aot.is_aot == "aot")
  56. local name = pretty_names[lua.code]
  57. local instr = (aot.instr / lua.instr) * 100.0
  58. local cycle = (aot.cycle / lua.cycle) * 100.0
  59. print(string.format("%-14s & %3.1f & %3.1f \\\\", name, instr, cycle))
  60. end