condy0919 / fanyi.el

Not only English-Chinese translator for Emacs.
GNU General Public License v3.0
79 stars 7 forks source link

[longman] certain lookup take long time #19

Open emacsbliss opened 2 years ago

emacsbliss commented 2 years ago

for some reason certain words takes long time to get the result displayed in buffer..

few examples:

condy0919 commented 2 years ago

Does

curl "https://www.ldoceonline.com/dictionary/successful"

have the same issue?

Since fanyi.el uses url-retrieve, it may be suffered from the network jitter

emacsbliss commented 2 years ago

curl seems to return pretty quickly.. wondering would it be rendering issue?

condy0919 commented 2 years ago
(setq longman-ins (clone fanyi-longman-provider))
(oset longman-ins :word "successful")
(fanyi--spawn longman-ins)

;; Wait until *fanyi* buffer has a longman section which means longman-ins has parsed the result.
;;
;; benchmark the render function.
(benchmark-run 10 (fanyi-render longman-ins))
;;=> (0.150839075 0 0.0)

It costs 0.015s per render on my machine.

PS: switch to *fanyi* buffer will see 11 sections of longman dict. one is created by fanyi--spawn.