(Pathinfo 与 fnmatch 第 2 部分)Windows 和 Mac 上的速度基准相反

发布于 2024-08-31 15:16:32 字数 350 浏览 0 评论 0原文

在上一个问题中,对 pathinfo 和 fnmatch 函数进行了基准测试,结果都与我的基准测试结果相反

您可以在此处使用基准代码读取不同的结果: pathinfo 与 fnmatch

我无法解决这个问题,直到我在运行 vista 的计算机上运行相同的代码。然后结果与其他用户相匹配。我的主机是mac。

所以,我的问题是:

  • 为什么我们会得到这两个不同的结果?
  • 这可以适用于其他功能吗?

On a previous question the pathinfo and fnmatch functions were benchmarked and the answers all came out opposite to my benchmark results.

You can read the different results with the benchmark code here:
pathinfo vs fnmatch

I couldn't work it out until I ran the same code on a machine running vista. The results then matched the other users. My main machine is a mac.

So, my questions are:

  • Why do we get these two different results?
  • Could this apply to other functions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

-残月青衣踏尘吟 2024-09-07 15:16:32

为什么我们会得到这两个不同的结果
结果?

fnmatch 应映射到操作系统的底层 fnmatch 命令(Windows 没有此类命令,并且在 PHP 5.3 之前不可用)。苹果执行该命令的速度肯定要慢一些。

这可以应用于其他功能吗?

您可以检查 glob() 的速度问题,因为它也执行正则表达式关于文件名。

编辑: Glob 不使用正则表达式。它,嗯,球状的。 (感谢萨拉特)

Why do we get these two different
results?

fnmatch should be mapped to the OS's underlying fnmatch command (Windows has no such command and was unavailable until PHP 5.3). Apple's implementation of the command must be less speedy.

Could this apply to other functions?

You could check glob() for speed issues as it also performs regex on filenames.

Edit: Glob does not regex. It, well, globs. (thanks to salathe)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文