astoff / devdocs.el

Emacs viewer for DevDocs
279 stars 16 forks source link

Use native JSON parsing availible in Emacs 27 and report progress #19

Closed juergenhoetzel closed 2 years ago

juergenhoetzel commented 2 years ago

Writing a huge amount of HTML files can take a while to finish. Inform the user about the progress so the user can estimate remaining time and clearly see that Emacs is busy working, not hung.

Speed Improvement

;; Current implementation
(benchmark 1 '(devdocs-install '((name . "PHP") (slug . "php") (type . "php") (links (home . "https://www.php.net/") (code . "https://git.php.net/?p=php-src.git;a=summary")) (release . "8.1.5") (mtime . 1650899439) (db_size . 25993841))))
"Elapsed time: 17.163928s (6.059382s in 93 GCs)"
;; This commit
(benchmark 1 '(devdocs-install '((name . "PHP") (slug . "php") (type . "php") (links (home . "https://www.php.net/") (code . "https://git.php.net/?p=php-src.git;a=summary")) (release . "8.1.5") (mtime . 1650899439) (db_size . 25993841))))
"Elapsed time: 12.833806s (2.523597s in 39 GCs)"
astoff commented 2 years ago

Adding a progress reporter sounds good, thanks for the idea.

As to the JSON parsing, Emacs can be compiled without libjansson, in which case json-parse-buffer is not defined. Sadly, we'd have to check and define a fallback behavior manually if we want to use the native JSON parsing. I think this not worth the trouble in this particular application.

astoff commented 2 years ago

I've added a progress reporter in https://github.com/astoff/devdocs.el/commit/d5d0cfbfbcd037ef8f84f41b2adc3f5a23baa11f as you suggested here.

As is mentioned, the better JSON parser can be used only if a better compatibility layer is introduced somewhere else (maybe we can start using the compat library in the future).