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

对第一册p298页的结果有疑问 #27

Closed
MrBear2018 opened this issue Aug 27, 2022 · 2 comments
Closed

对第一册p298页的结果有疑问 #27

MrBear2018 opened this issue Aug 27, 2022 · 2 comments

Comments

@MrBear2018
Copy link

MrBear2018 commented Aug 27, 2022

我们看到, 在并发流水线启动预热并正式工作之后, 30名旅客的安检时长已经从3600下降到2160, 并发方案使得安检通道的效率有了进一步提升. 如果流水线持续工作, 效率应该会稳定在 1200(3600/3) 左右.

我对这里的 1200 有不同的看法.
如您书里面所说, 三个步骤耗时分别是

idCheckTmCost   = 60
bodyCheckTmCost = 120
xRayCheckTmCost = 180

对于第三版安检线路, 由于每个模块都是并发执行, 因此这条线路的耗时取决于本线路中耗时最长的模块的总耗时.
这个耗时最高的模块就是xRayCheck模块

假设有1条这样的安检线路, 则耗时应该是: xRayCheckTmCost * 30 = 30 * 180 = 5400
假设有3条这样的安检线路, 则理想情况下的耗时应该是 xRayCheckTmCost * (30/3) = 180 * 10 = 1800

您这里简单的用 3600/3 = 1200 作为最终的最短耗时预期是不合理的

@MrBear2018
Copy link
Author

补充一下我看到的书籍版本信息:
Go语言精进之路
从新手到高手的编程思想、方法和技巧 1
版次: 2022年1月第一版第一次印刷

@bigwhite
Copy link
Owner

bigwhite commented Sep 3, 2022

有道理。书中的确考虑简单了。当每个安检线路“流水线”流满后,其处理能力的确应以最长的check为准,也就是xRayCheckTmCost的180s为一跳。后续更到errata.md中。感谢指出。

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

2 participants