21 #include "benchmark/benchmark.h" 27 void BM_CUnescapeHexString(benchmark::State& state) {
29 for (
int i = 0;
i < 50;
i++) {
33 for (
auto _ : state) {
37 BENCHMARK(BM_CUnescapeHexString);
39 void BM_WebSafeBase64Escape_string(benchmark::State& state) {
41 for (
int i = 0;
i < 10; ++
i) {
43 raw += std::string(test_set.plaintext);
49 for (
auto _ : state) {
56 std::string round_trip;
60 BENCHMARK(BM_WebSafeBase64Escape_string);
63 const char kStringValueNoEscape[] =
"1234567890";
64 const char kStringValueSomeEscaped[] =
"123\n56789\xA1";
65 const char kStringValueMostEscaped[] =
"\xA1\xA2\ny\xA4\xA5\xA6z\b\r";
67 void CEscapeBenchmarkHelper(benchmark::State& state,
const char* string_value,
70 while (src.size() < max_len) {
74 for (
auto _ : state) {
79 void BM_CEscape_NoEscape(benchmark::State& state) {
80 CEscapeBenchmarkHelper(state, kStringValueNoEscape, state.range(0));
82 BENCHMARK(BM_CEscape_NoEscape)->Range(1, 1 << 14);
84 void BM_CEscape_SomeEscaped(benchmark::State& state) {
85 CEscapeBenchmarkHelper(state, kStringValueSomeEscaped, state.range(0));
87 BENCHMARK(BM_CEscape_SomeEscaped)->Range(1, 1 << 14);
89 void BM_CEscape_MostEscaped(benchmark::State& state) {
90 CEscapeBenchmarkHelper(state, kStringValueMostEscaped, state.range(0));
92 BENCHMARK(BM_CEscape_MostEscaped)->Range(1, 1 << 14);
void StrAppend(std::string *dest, const AlphaNum &a)
const std::array< base64_testcase, 5 > & base64_strings()
std::string CEscape(absl::string_view src)
bool WebSafeBase64Unescape(absl::string_view src, std::string *dest)
void WebSafeBase64Escape(absl::string_view src, std::string *dest)
#define ABSL_RAW_CHECK(condition, message)
bool CUnescape(absl::string_view source, std::string *dest, std::string *error)