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

可以考虑使用build script来构建 #34

Closed
upsuper opened this issue May 19, 2019 · 9 comments
Closed

可以考虑使用build script来构建 #34

upsuper opened this issue May 19, 2019 · 9 comments

Comments

@upsuper
Copy link
Collaborator

upsuper commented May 19, 2019

可以将生成字典的过程放在 build.rs 里,这样就不需要单独的 Makefile 了,也不需要将字典文件单独签入代码库。

此外使用build script以后,还可以使用phf(配合phf_codegen)构建哈希表,这样在运行时效率也可以得到保证。

@mozillazg
Copy link
Owner

@upsuper 之所以没用 phf 以及 build.rs 的原因这里有解释:#27 (comment)

@upsuper
Copy link
Collaborator Author

upsuper commented May 19, 2019

我……不是很同意这个见解 :) 不过既然如此那看起来改回去的PR是不会被接受的了

@upsuper upsuper closed this as completed May 19, 2019
@mozillazg
Copy link
Owner

@upsuper 可以讨论的,#27 (comment) 那里也提到了用 phf 是可以接受的,只是说倾向于把生成字典文件的操作放到 makefile 里,毕竟之前用 bulid.rs 的时候是有点慢,编译一次要几十分钟。 @LuoZijun 大佬咋说? (可以参考一下 #33 的问题

@mozillazg mozillazg reopened this May 19, 2019
@upsuper
Copy link
Collaborator Author

upsuper commented May 19, 2019

编译一次要几十分钟?!这是有点夸张……

@LuoZijun
Copy link
Collaborator

编译一次要几十分钟?!这是有点夸张……

我印象当中应该是十几分钟(确信是分钟级别的),硬件是 MacBook Pro 。

这段时间 Rust 的编译器的编译速度也得到了不少提升,所以在当前的版本下也许会快不少?我稍晚一些做个测试。

@LuoZijun
Copy link
Collaborator

@upsuper @mozillazg 我刚才重新做了下测试,2年多过去后(耗时长的问题出现在 2017年),phf 代码生成速度已经是以为单位了。所以编译速度已经不再是个问题。

但是采用 phf 来替代二分查找算法并没有带来微小的性能提升。所以新的问题大概就是还有没有必要迁回 phf 这种模式 ...

测试样本是 钱钟书的《围城》: https://github.com/mozillazg/rust-pinyin/blob/add-hashmap/data/weicheng.txt

build.rs: https://github.com/mozillazg/rust-pinyin/blob/add-hashmap/build.rs

@upsuper
Copy link
Collaborator Author

upsuper commented May 21, 2019

话说……围城的版权可还没过期啊……

@LuoZijun
Copy link
Collaborator

@upsuper 额,没注意这个问题 ...

@LuoZijun
Copy link
Collaborator

PR #36 已经采用了构建脚本且已经合并进 develop 分支,所以这里就先关闭了。

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

No branches or pull requests

3 participants