谷歌基准测试:断言"has_range_x_"失败
google benchmark: Assertion `has_range_x_' failed
在一个项目中,我开始从https://github.com/google/benchmark.git标签v1.0.0。
我运行了一个非常简单的测试
#include <benchmark/benchmark.h>
#include <cstring>
static void BM_memcpy(benchmark::State& state) {
char* src = new char[state.range_x()]; char* dst = new char[state.range_x()];
memset(src, 'x', state.range_x());
while (state.KeepRunning())
memcpy(dst, src, state.range_x());
state.SetBytesProcessed(int64_t(state.iterations()) *
int64_t(state.range_x()));
delete[] src;
delete[] dst;
}
BENCHMARK(BM_memcpy)->Arg(8)->Arg(64)->Arg(512)->Arg(1<<10)->Arg(8<<10);
// Register the function as a benchmark
BENCHMARK(BM_memcpy);
BENCHMARK_MAIN();
但是我得到错误
./bench/simple-benchmark
Run on (8 X 4000 MHz CPU s)
2016-08-02 18:22:30
Benchmark Time CPU Iterations
-----------------------------------------------------
BM_memcpy/8 9 ns 9 ns 79545455 877MB/s
BM_memcpy/64 9 ns 9 ns 56451613 6.67615GB/s
BM_memcpy/512 21 ns 21 ns 33018868 23.0185GB/s
BM_memcpy/1024 30 ns 29 ns 23648649 32.4039GB/s
BM_memcpy/8k 516 ns 514 ns 1346154 14.8415GB/s
simple-idl-benchmark: /usr/local/include/benchmark/benchmark_api.h:417: int benchmark::State::range_x() const: Assertion `has_range_x_' failed.
我尝试了master和旧标签,但我总是得到这个断言。我在debian/testing上使用了gcc 5.4.0来测试基准库和简单的基准可执行文件。
对我来说,它似乎无法检测到参数列表的末尾,并断言。但是怎么了?如何预防?
您注册了两次基准测试(对BENCHMARK
的调用),但第二次没有提供Arg
。也就是说,你调用它时没有设置范围,就像断言所断言的那样。
相关文章:
- 如果没有malloc,链表实现将失败
- 模板参数替换失败,并且未完成隐式转换
- 具有默认模板参数的多态类的模板推导失败
- 视图中的参数推导失败:take_while
- 链接到自行创建的dll失败
- 带有特殊路径部分的"std::filesystem::weakly_canonical"失败
- GetShortPathName在网络驱动器上使用中文文件夹时失败
- gcc和c++17的过载解析失败
- 为什么使用 P/Invoke 调用 dll 时,某些计算机中的 LoadLibrary 失败?
- 在WSL:configure_file上对config_file的每次调用都失败:配置文件时出现问题
- 使用 GCC 卸载的 OpenMP 卸载失败,并出现"Ptx assembly aborted due to errors"
- 使用cmake从源代码构建MySQL连接器/C++失败(与以前的声明冲突)
- 链接阶段在Ubuntu上失败,但在MacOS上失败
- 从父数组测试用例构造二叉树失败
- LibGit2 SSH身份验证失败
- 如何让LLDB在成功时退出,在失败时等待
- VS2017,C++包含目录与附加包含目录,子文件夹包含失败-但为什么
- 生成MRPT库时cmake配置失败
- QList::operator[]中的断言失败<T>:QJoysticks 中的"index out of range"
- QList<T>::operator[]: "index out of range" 中的断言失败