/*
 * Copyright 2021 VMware, Inc.
 * SPDX-License-Identifier: PostgreSQL
 */

#include <benchmark/benchmark.h>

#include <libpq-fe.h>

static void BM_Ascii(benchmark::State& state)
{
    int enc = pg_char_to_encoding("UTF8");

    for (auto _ : state) {
        PQdsplen("a", enc);
    }
}

BENCHMARK(BM_Ascii);

static void BM_Emoji(benchmark::State& state)
{
    int enc = pg_char_to_encoding("UTF8");

    for (auto _ : state) {
        PQdsplen(u8"\U0001F600", enc);
    }
}

BENCHMARK(BM_Emoji);

static void BM_Worst(benchmark::State& state)
{
    int enc = pg_char_to_encoding("UTF8");

    for (auto _ : state) {
        PQdsplen(u8"\u115F", enc);
    }
}

BENCHMARK(BM_Worst);

BENCHMARK_MAIN();
