| 405 | |
| 406 | template <typename T, typename DecodeFunc> |
| 407 | static void BM_ByteStreamSplitDecode(benchmark::State& state, DecodeFunc&& decode_func) { |
| 408 | const std::vector<T> values(state.range(0), ByteStreamSplitDummyValue<T>::value()); |
| 409 | const uint8_t* values_raw = reinterpret_cast<const uint8_t*>(values.data()); |
| 410 | std::vector<T> output(state.range(0)); |
| 411 | |
| 412 | for (auto _ : state) { |
| 413 | decode_func(values_raw, |
| 414 | /*width=*/static_cast<int>(sizeof(T)), |
| 415 | /*num_values=*/static_cast<int64_t>(values.size()), |
| 416 | /*stride=*/static_cast<int64_t>(values.size()), |
| 417 | reinterpret_cast<uint8_t*>(output.data())); |
| 418 | benchmark::ClobberMemory(); |
| 419 | } |
| 420 | state.SetBytesProcessed(state.iterations() * values.size() * sizeof(T)); |
| 421 | state.SetItemsProcessed(state.iterations() * values.size()); |
| 422 | } |
| 423 | |
| 424 | template <typename T, typename EncodeFunc> |
| 425 | static void BM_ByteStreamSplitEncode(benchmark::State& state, EncodeFunc&& encode_func) { |