Skip to content
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

Improve performance of runSnippetCursor #323

Merged
merged 1 commit into from
Aug 25, 2024

Conversation

shunby
Copy link
Contributor

@shunby shunby commented Aug 25, 2024

Optimizes runSnippetCursor in run_snippet.ts by reducing redundant calls to view.state.sliceDoc.
Partially solves #320 by improving the editting of large files.

Performance Testing

Tested with a large markdown file generated with the following command:

python -c "print('aa\n'*4000)" > test.md

Pushed a key when the cursor is at the bottom of the file and measured the time spent handling the keydown event using DevTools.

Test Environment:

  • OS: Microsoft Windows 11 Home
  • CPU: Intel(R) Core(TM) i7-8750H CPU
  • RAM: 16GB

Results:

  • Before the update: Handling a single keydown event took approximately 50ms, with runSnippetCursor consuming 47ms.
  • After the update: Handling a single keydown event took approximately 3ms, with runSnippetCursor consuming 0.2ms.

@artisticat1 artisticat1 merged commit 49c91e1 into artisticat1:main Aug 25, 2024
@artisticat1
Copy link
Owner

Thanks!

@CamWam
Copy link

CamWam commented Aug 27, 2024

Thank you!!!!

@bdm-k bdm-k deleted the dev-perf-runsnippet branch September 7, 2024 17:50
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.

3 participants