// Copyright 2019 The Cobalt Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <cstring>

#include "starboard/memory.h"

#include "third_party/google_benchmark/src/include/benchmark/benchmark.h"

namespace starboard {
namespace benchmark {
namespace {

void BM_MemoryCopy(::benchmark::State& state) {
  void* memory1 = malloc(state.range(0));
  void* memory2 = malloc(state.range(0));

  for (auto _ : state) {
    memcpy(memory1, memory2, state.range(0));
    ::benchmark::ClobberMemory();
  }
  state.SetBytesProcessed(int64_t(state.iterations()) *
                          int64_t(state.range(0)));

  free(memory1);
  free(memory2);
}

void BM_MemoryMove(::benchmark::State& state) {
  void* memory1 = malloc(state.range(0));
  void* memory2 = malloc(state.range(0));

  for (auto _ : state) {
    memmove(memory1, memory2, state.range(0));
    ::benchmark::ClobberMemory();
  }
  state.SetBytesProcessed(int64_t(state.iterations()) *
                          int64_t(state.range(0)));

  free(memory1);
  free(memory2);
}

BENCHMARK(BM_MemoryCopy)->RangeMultiplier(4)->Range(16, 1024 * 1024);
BENCHMARK(BM_MemoryCopy)
    ->Arg(1024 * 1024)
    ->DenseThreadRange(1, 4)
    ->UseRealTime();
BENCHMARK(BM_MemoryMove)->Arg(1024 * 1024);

}  // namespace
}  // namespace benchmark
}  // namespace starboard
