Skip to content

perf: native io function instead of File class #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 15, 2025
Merged

perf: native io function instead of File class #209

merged 12 commits into from
Jun 15, 2025

Conversation

neo451
Copy link
Member

@neo451 neo451 commented Jun 14, 2025

  • Use native lua io function to replace File class that depends on plenary

faster after benchmark:

local function bench(f, name)
  local t = os.clock()

  for _ = 1, 100000 do
    f()
  end

  print(name, os.clock() - t)
end

local note = require "obsidian.note"
local async = require "plenary.async"

bench(function()
  note.from_file_async2 "~/Notes/21-30 Tinker/12 Open Source/12.1 obsidian.nvim/lsp proposal.md"
end, "new")

bench(function()
  async.util.block_on(function()
    note.from_file_async "~/Notes/21-30 Tinker/12 Open Source/12.1 obsidian.nvim/lsp proposal.md"
  end)
end, "old")

-- new 5s
-- old 6s
  • improved some tests

PR Checklist

  • The PR contains a description of the changes
  • I read the [CONTRIBUTING.md] file
  • The CHANGELOG.md is updated
  • The changes are documented in the README.md file
  • The code complies with make chores (for style, lint, types, and tests)

@neo451 neo451 changed the title fix(note): Note.from_file_async use lua io.open, faster perf: native io function instead of File class Jun 15, 2025
@neo451 neo451 merged commit 10ef028 into main Jun 15, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant