Exemple #1
0
void HexEncode(not_null<benchmark::State*> const state,
              not_null<bool*> const correct,
              std::vector<uint8_t> const& input_bytes,
              std::vector<uint8_t> const& expected_digits) {
  state->PauseTiming();
  std::vector<uint8_t> digits(input_bytes.size() << 1);
  state->ResumeTiming();
  HexadecimalEncode({input_bytes.data(), input_bytes.size()},
                    {digits.data(), digits.size()});
  state->PauseTiming();
  *correct &= digits == expected_digits;
  state->ResumeTiming();
}
Exemple #2
0
void HexDecode(not_null<benchmark::State*> const state,
               not_null<bool*> const correct,
               std::vector<uint8_t> const& input_digits,
               std::vector<uint8_t> const& expected_bytes) {
  state->PauseTiming();
  std::vector<uint8_t> bytes(input_digits.size() / 2);
  state->ResumeTiming();
  HexadecimalDecode({input_digits.data(), input_digits.size()},
                    {bytes.data(), bytes.size()});
  state->PauseTiming();
  *correct &= bytes == expected_bytes;
  state->ResumeTiming();
}