graphcycles_benchmark.cc
Go to the documentation of this file.
1 // Copyright 2018 The Abseil Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
16 
17 #include <algorithm>
18 #include <cstdint>
19 #include <vector>
20 
21 #include "benchmark/benchmark.h"
23 
24 namespace {
25 
26 void BM_StressTest(benchmark::State& state) {
27  const int num_nodes = state.range(0);
28  while (state.KeepRunningBatch(num_nodes)) {
30  std::vector<absl::synchronization_internal::GraphId> nodes(num_nodes);
31  for (int i = 0; i < num_nodes; i++) {
32  nodes[i] = g.GetId(reinterpret_cast<void*>(static_cast<uintptr_t>(i)));
33  }
34  for (int i = 0; i < num_nodes; i++) {
35  int end = std::min(num_nodes, i + 5);
36  for (int j = i + 1; j < end; j++) {
37  ABSL_RAW_CHECK(g.InsertEdge(nodes[i], nodes[j]), "");
38  }
39  }
40  }
41 }
42 BENCHMARK(BM_StressTest)->Range(2048, 1048576);
43 
44 } // namespace
bool InsertEdge(GraphId source_node, GraphId dest_node)
Definition: graphcycles.cc:491
char * end
#define ABSL_RAW_CHECK(condition, message)
Definition: raw_logging.h:57


abseil_cpp
Author(s):
autogenerated on Tue Jun 18 2019 19:44:36