Some checks failed
		
		
	
	Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
				
			Detach Plugins / check (GitHub.vim) (push) Has been cancelled
				
			Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
				
			Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
				
			Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
				
			Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
				
			Detach Plugins / check (git.vim) (push) Has been cancelled
				
			Detach Plugins / check (iedit.vim) (push) Has been cancelled
				
			Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
				
			Detach Plugins / check (vim-chat) (push) Has been cancelled
				
			Detach Plugins / check (vim-cheat) (push) Has been cancelled
				
			Detach Plugins / check (vim-todo) (push) Has been cancelled
				
			Detach Plugins / check (xmake.vim) (push) Has been cancelled
				
			test / Linux (nvim, nightly) (push) Has been cancelled
				
			test / Linux (nvim, v0.3.8) (push) Has been cancelled
				
			test / Linux (nvim, v0.4.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.4.2) (push) Has been cancelled
				
			test / Linux (nvim, v0.4.3) (push) Has been cancelled
				
			test / Linux (nvim, v0.4.4) (push) Has been cancelled
				
			test / Linux (nvim, v0.5.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.5.1) (push) Has been cancelled
				
			test / Linux (nvim, v0.6.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.6.1) (push) Has been cancelled
				
			test / Linux (nvim, v0.7.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.7.2) (push) Has been cancelled
				
			test / Linux (nvim, v0.8.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.8.1) (push) Has been cancelled
				
			test / Linux (nvim, v0.8.2) (push) Has been cancelled
				
			test / Linux (nvim, v0.8.3) (push) Has been cancelled
				
			test / Linux (nvim, v0.9.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.9.1) (push) Has been cancelled
				
			test / Linux (true, vim, v7.4.052) (push) Has been cancelled
				
			test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
				
			test / Linux (true, vim, v7.4.629) (push) Has been cancelled
				
			test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
				
			test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
				
			test / Linux (vim, nightly) (push) Has been cancelled
				
			test / Linux (vim, v8.0.0184) (push) Has been cancelled
				
			test / Linux (vim, v8.0.1453) (push) Has been cancelled
				
			test / Linux (vim, v8.1.2269) (push) Has been cancelled
				
			test / Linux (vim, v8.2.2434) (push) Has been cancelled
				
			test / Linux (vim, v8.2.3995) (push) Has been cancelled
				
			test / Windows (nvim, nightly) (push) Has been cancelled
				
			test / Windows (nvim, v0.3.8) (push) Has been cancelled
				
			test / Windows (nvim, v0.4.2) (push) Has been cancelled
				
			test / Windows (nvim, v0.4.3) (push) Has been cancelled
				
			test / Windows (nvim, v0.4.4) (push) Has been cancelled
				
			test / Windows (nvim, v0.5.0) (push) Has been cancelled
				
			test / Windows (nvim, v0.5.1) (push) Has been cancelled
				
			test / Windows (nvim, v0.6.0) (push) Has been cancelled
				
			test / Windows (nvim, v0.6.1) (push) Has been cancelled
				
			test / Windows (nvim, v0.7.0) (push) Has been cancelled
				
			test / Windows (nvim, v0.7.2) (push) Has been cancelled
				
			test / Windows (nvim, v0.8.0) (push) Has been cancelled
				
			test / Windows (nvim, v0.8.1) (push) Has been cancelled
				
			test / Windows (nvim, v0.8.2) (push) Has been cancelled
				
			test / Windows (nvim, v0.8.3) (push) Has been cancelled
				
			test / Windows (nvim, v0.9.0) (push) Has been cancelled
				
			test / Windows (nvim, v0.9.1) (push) Has been cancelled
				
			test / Windows (vim, nightly) (push) Has been cancelled
				
			test / Windows (vim, v7.4.1185) (push) Has been cancelled
				
			test / Windows (vim, v7.4.1689) (push) Has been cancelled
				
			test / Windows (vim, v8.0.0027) (push) Has been cancelled
				
			test / Windows (vim, v8.0.1453) (push) Has been cancelled
				
			test / Windows (vim, v8.1.2269) (push) Has been cancelled
				
			test / Windows (vim, v8.2.2434) (push) Has been cancelled
				
			test / Windows (vim, v8.2.3995) (push) Has been cancelled
				
			docker / docker (push) Has been cancelled
				
			mirror / check (coding) (push) Has been cancelled
				
			mirror / check (gitee) (push) Has been cancelled
				
			mirror / check (gitlab) (push) Has been cancelled
				
			
		
			
				
	
	
		
			253 lines
		
	
	
		
			6.5 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			253 lines
		
	
	
		
			6.5 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
--[[ Copyright (c) 2018-2020, Charles Mallah ]]
 | 
						|
-- Released with MIT License
 | 
						|
--
 | 
						|
-- Originally link:
 | 
						|
--  https://github.com/charlesmallah/lua-profiler
 | 
						|
--
 | 
						|
-- Hopefully will add some better neovim stuff in the future.
 | 
						|
-- Shoutout to @clason for finding this.
 | 
						|
 | 
						|
 | 
						|
---------------------------------------|
 | 
						|
--- Configuration
 | 
						|
--
 | 
						|
---------------------------------------|
 | 
						|
 | 
						|
local PROFILER_FILENAME = "lua/telescope/profile/lua_profiler.lua" -- Location and name of profiler (to remove itself from reports);
 | 
						|
-- e.g. if this is in a 'tool' folder, rename this as: "tool/profiler.lua"
 | 
						|
 | 
						|
local EMPTY_TIME = "0.0000" -- Detect empty time, replace with tag below
 | 
						|
local emptyToThis = "~"
 | 
						|
 | 
						|
local fileWidth = 75
 | 
						|
local funcWidth = 22
 | 
						|
local lineWidth = 6
 | 
						|
local timeWidth = 7
 | 
						|
local relaWidth = 6
 | 
						|
local callWidth = 4
 | 
						|
 | 
						|
local reportSaved = " > Report saved to"
 | 
						|
local formatOutputHeader = "| %-"..fileWidth.."s: %-"..funcWidth.."s: %-"..lineWidth.."s: %-"..timeWidth.."s: %-"..relaWidth.."s: %-"..callWidth.."s|\n"
 | 
						|
local formatOutputTitle = "%-"..fileWidth.."."..fileWidth.."s: %-"..funcWidth.."."..funcWidth.."s: %-"..lineWidth.."s" -- File / Function / Line count
 | 
						|
local formatOutput = "| %s: %-"..timeWidth.."s: %-"..relaWidth.."s: %-"..callWidth.."s|\n" -- Time / Relative / Called
 | 
						|
local formatTotalTime = "TOTAL TIME   = %f s\n"
 | 
						|
local formatFunLine = "%"..(lineWidth - 2).."i"
 | 
						|
local formatFunTime = "%04.4f"
 | 
						|
local formatFunRelative = "%03.1f"
 | 
						|
local formatFunCount = "%"..(callWidth - 1).."i"
 | 
						|
local formatHeader = string.format(formatOutputHeader, "FILE", "FUNCTION", "LINE", "TIME", "%", "#")
 | 
						|
 | 
						|
 | 
						|
---------------------------------------|
 | 
						|
--- Locals
 | 
						|
--
 | 
						|
---------------------------------------|
 | 
						|
 | 
						|
local module = {}
 | 
						|
 | 
						|
local getTime = os.clock
 | 
						|
local string = string
 | 
						|
local debug = debug
 | 
						|
local table = table
 | 
						|
 | 
						|
local TABL_REPORT_CACHE = {}
 | 
						|
local TABL_REPORTS = {}
 | 
						|
local reportCount = 0
 | 
						|
local startTime = 0
 | 
						|
local stopTime = 0
 | 
						|
 | 
						|
local printFun = nil
 | 
						|
local verbosePrint = false
 | 
						|
 | 
						|
local function functionReport(information)
 | 
						|
  local src = information.short_src
 | 
						|
  if src == nil then
 | 
						|
    src = "<C>"
 | 
						|
  elseif string.sub(src, #src - 3, #src) == ".lua" then
 | 
						|
    src = string.sub(src, 1, #src - 4)
 | 
						|
  end
 | 
						|
 | 
						|
  local name = information.name
 | 
						|
  if name == nil then
 | 
						|
    name = "Anon"
 | 
						|
  elseif string.sub(name, #name - 1, #name) == "_l" then
 | 
						|
    name = string.sub(name, 1, #name - 2)
 | 
						|
  end
 | 
						|
 | 
						|
  local title = string.format(formatOutputTitle,
 | 
						|
    src, name,
 | 
						|
  string.format(formatFunLine, information.linedefined or 0))
 | 
						|
 | 
						|
  local funcReport = TABL_REPORT_CACHE[title]
 | 
						|
  if not funcReport then
 | 
						|
    funcReport = {
 | 
						|
      title = string.format(formatOutputTitle,
 | 
						|
        src, name,
 | 
						|
      string.format(formatFunLine, information.linedefined or 0)),
 | 
						|
      count = 0,
 | 
						|
      timer = 0,
 | 
						|
    }
 | 
						|
    TABL_REPORT_CACHE[title] = funcReport
 | 
						|
    reportCount = reportCount + 1
 | 
						|
    TABL_REPORTS[reportCount] = funcReport
 | 
						|
  end
 | 
						|
 | 
						|
  return funcReport
 | 
						|
end
 | 
						|
 | 
						|
local onDebugHook = function(hookType)
 | 
						|
  local information = debug.getinfo(2, "nS")
 | 
						|
  if hookType == "call" then
 | 
						|
    local funcReport = functionReport(information)
 | 
						|
    funcReport.callTime = getTime()
 | 
						|
    funcReport.count = funcReport.count + 1
 | 
						|
  elseif hookType == "return" then
 | 
						|
    local funcReport = functionReport(information)
 | 
						|
    if funcReport.callTime and funcReport.count > 0 then
 | 
						|
      funcReport.timer = funcReport.timer + (getTime() - funcReport.callTime)
 | 
						|
    end
 | 
						|
  end
 | 
						|
end
 | 
						|
 | 
						|
local function charRepetition(n, character)
 | 
						|
  local s = ""
 | 
						|
  character = character or " "
 | 
						|
  for _ = 1, n do
 | 
						|
    s = s..character
 | 
						|
  end
 | 
						|
  return s
 | 
						|
end
 | 
						|
 | 
						|
local function singleSearchReturn(str, search)
 | 
						|
  for _ in string.gmatch(str, search) do
 | 
						|
    do return true end
 | 
						|
  end
 | 
						|
  return false
 | 
						|
end
 | 
						|
 | 
						|
local divider = charRepetition(#formatHeader - 1, "-").."\n"
 | 
						|
 | 
						|
 | 
						|
---------------------------------------|
 | 
						|
--- Functions
 | 
						|
--
 | 
						|
---------------------------------------|
 | 
						|
 | 
						|
--- Attach a print function to the profiler, to receive a single string parameter
 | 
						|
--
 | 
						|
function module.attachPrintFunction(fn, verbose)
 | 
						|
  printFun = fn
 | 
						|
  if verbose ~= nil then
 | 
						|
    verbosePrint = verbose
 | 
						|
  end
 | 
						|
end
 | 
						|
 | 
						|
---
 | 
						|
--
 | 
						|
function module.start()
 | 
						|
  TABL_REPORT_CACHE = {}
 | 
						|
  TABL_REPORTS = {}
 | 
						|
  reportCount = 0
 | 
						|
  startTime = getTime()
 | 
						|
  stopTime = nil
 | 
						|
  debug.sethook(onDebugHook, "cr", 0)
 | 
						|
end
 | 
						|
 | 
						|
---
 | 
						|
--
 | 
						|
function module.stop()
 | 
						|
  stopTime = getTime()
 | 
						|
  debug.sethook()
 | 
						|
end
 | 
						|
 | 
						|
--- Writes the profile report to file
 | 
						|
--
 | 
						|
function module.report(filename)
 | 
						|
  if stopTime == nil then
 | 
						|
    module.stop()
 | 
						|
  end
 | 
						|
 | 
						|
  if reportCount > 0 then
 | 
						|
    filename = filename or "profiler.log"
 | 
						|
    table.sort(TABL_REPORTS, function(a, b) return a.timer > b.timer end)
 | 
						|
    local file = io.open(filename, "w+")
 | 
						|
 | 
						|
    if reportCount > 0 then
 | 
						|
      local divide = false
 | 
						|
      local totalTime = stopTime - startTime
 | 
						|
      local totalTimeOutput = " > "..string.format(formatTotalTime, totalTime)
 | 
						|
 | 
						|
      file:write(totalTimeOutput)
 | 
						|
      if printFun ~= nil then
 | 
						|
        printFun(totalTimeOutput)
 | 
						|
      end
 | 
						|
 | 
						|
      file:write("\n"..divider)
 | 
						|
      file:write(formatHeader)
 | 
						|
      file:write(divider)
 | 
						|
 | 
						|
      for i = 1, reportCount do
 | 
						|
        local funcReport = TABL_REPORTS[i]
 | 
						|
 | 
						|
        if funcReport.count > 0 and funcReport.timer <= totalTime then
 | 
						|
          local printThis = true
 | 
						|
 | 
						|
          if PROFILER_FILENAME ~= "" then
 | 
						|
            if singleSearchReturn(funcReport.title, PROFILER_FILENAME) then
 | 
						|
              printThis = false
 | 
						|
            end
 | 
						|
          end
 | 
						|
 | 
						|
          -- Remove line if not needed
 | 
						|
          if printThis == true then
 | 
						|
            if singleSearchReturn(funcReport.title, "[[C]]") then
 | 
						|
              printThis = false
 | 
						|
            end
 | 
						|
          end
 | 
						|
 | 
						|
          if printThis == true then
 | 
						|
            local count = string.format(formatFunCount, funcReport.count)
 | 
						|
            local timer = string.format(formatFunTime, funcReport.timer)
 | 
						|
            local relTime = string.format(formatFunRelative, (funcReport.timer / totalTime) * 100)
 | 
						|
            if divide == false and timer == EMPTY_TIME then
 | 
						|
              file:write(divider)
 | 
						|
              divide = true
 | 
						|
            end
 | 
						|
 | 
						|
            -- Replace
 | 
						|
            if timer == EMPTY_TIME then
 | 
						|
              timer = emptyToThis
 | 
						|
              relTime = emptyToThis
 | 
						|
            end
 | 
						|
 | 
						|
            -- Build final line
 | 
						|
            local outputLine = string.format(formatOutput, funcReport.title, timer, relTime, count)
 | 
						|
            file:write(outputLine)
 | 
						|
 | 
						|
            -- This is a verbose print to the printFun, however maybe make this smaller for on screen debug?
 | 
						|
            if printFun ~= nil and verbosePrint == true then
 | 
						|
              printFun(outputLine)
 | 
						|
            end
 | 
						|
 | 
						|
          end
 | 
						|
        end
 | 
						|
      end
 | 
						|
 | 
						|
      file:write(divider)
 | 
						|
 | 
						|
    end
 | 
						|
 | 
						|
    file:close()
 | 
						|
 | 
						|
    if printFun ~= nil then
 | 
						|
      printFun(reportSaved.."'"..filename.."'")
 | 
						|
    end
 | 
						|
 | 
						|
  end
 | 
						|
 | 
						|
end
 | 
						|
 | 
						|
--- End
 | 
						|
--
 | 
						|
return module
 |