如何在https://quick-bench.com上基准fmt ::格式API

发布于 2025-02-10 07:08:16 字数 828 浏览 1 评论 0原文

我正在尝试理解和基准测试FMT ::格式化API( https:///fmt.dev/fmt.dev/latest/api/api/api/api-papi- .html )。我在编译器资源管理器中写了一个简单的测试。

#include <benchmark/benchmark.h>
#include <fmt/core.h>

static void BM_format(benchmark::State& state) {
  // Perform setup here
  for (auto _ : state) 
  {
      std::string s = fmt::format( "{}", "testing fmt::format in benchmark");
  }
}
// Register the function as a benchmark
BENCHMARK(BM_format);
// Run the benchmark
BENCHMARK_MAIN();

然后,我从Compile Explorer启动了快速基础。 在快速基础上,它给出了一个错误

错误或超时台式file.cpp:2:10:致命错误:fmt/core.h:否这样 文件或目录 2 | #include&lt; fmt/core.h&gt; | ^~~~~~~~~~~~~汇编终止。

C ++ FMT库是否在快速台上支持以使其编译和执行?如果没有,有其他选择。

I am trying to understand and benchmark fmt::format API ( https://fmt.dev/latest/api.html ). I wrote a simple test in compiler explorer i.e, https://godbolt.org/z/fMcf3nczE.

#include <benchmark/benchmark.h>
#include <fmt/core.h>

static void BM_format(benchmark::State& state) {
  // Perform setup here
  for (auto _ : state) 
  {
      std::string s = fmt::format( "{}", "testing fmt::format in benchmark");
  }
}
// Register the function as a benchmark
BENCHMARK(BM_format);
// Run the benchmark
BENCHMARK_MAIN();

Then, I launched quick-bench from compile explorer.
In quick-bench, it gives an error as

Error or timeout bench-file.cpp:2:10: fatal error: fmt/core.h: No such
file or directory
2 | #include <fmt/core.h>
| ^~~~~~~~~~~~ compilation terminated.

Is the c++ fmt library supported in quick-bench so that it compiles and executes? if not, any alternative.

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

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

发布评论

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

评论(1

寂寞美少年 2025-02-17 07:08:16

不幸的是,快速台不支持需要单独汇编的外部库( )。附带说明,它确实不支持包含在内通过URL的仅标题库。

我会说,在这种特定情况下,您可以使用C ++ 20 std ::格式,如果您不专门与FMT LIB相关。但是不幸的是,Clang 14和GCC 11(或更确切地说是LIBC ++和LIBSTDC ++)尚未实施。

因此,我担心您问的是完全不可能的。您需要在自己的计算机上进行基准测试。

Unfortunately, quick-bench does not support external libraries which require separate compilation (as fmt does). As a side note, it does not support the inclusion of header-only libraries via URLs, either.

I would have said that in this specific case you could use C++20 std::format instead, if you are not tied to fmt lib specifically. But unfortunately, neither clang 14 nor gcc 11 (or rather, libc++ and libstdc++) have implemented it yet.

So I fear what you ask is simply impossible right now. You need to benchmark on your own computer.

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