Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "absl/synchronization/internal/graphcycles.h"
00016
00017 #include <algorithm>
00018 #include <cstdint>
00019 #include <vector>
00020
00021 #include "benchmark/benchmark.h"
00022 #include "absl/base/internal/raw_logging.h"
00023
00024 namespace {
00025
00026 void BM_StressTest(benchmark::State& state) {
00027 const int num_nodes = state.range(0);
00028 while (state.KeepRunningBatch(num_nodes)) {
00029 absl::synchronization_internal::GraphCycles g;
00030 std::vector<absl::synchronization_internal::GraphId> nodes(num_nodes);
00031 for (int i = 0; i < num_nodes; i++) {
00032 nodes[i] = g.GetId(reinterpret_cast<void*>(static_cast<uintptr_t>(i)));
00033 }
00034 for (int i = 0; i < num_nodes; i++) {
00035 int end = std::min(num_nodes, i + 5);
00036 for (int j = i + 1; j < end; j++) {
00037 ABSL_RAW_CHECK(g.InsertEdge(nodes[i], nodes[j]), "");
00038 }
00039 }
00040 }
00041 }
00042 BENCHMARK(BM_StressTest)->Range(2048, 1048576);
00043
00044 }