| 661 | } |
| 662 | |
| 663 | static void BM_InEdgeIteration(int iters, int num_nodes, |
| 664 | int num_edges_per_node) { |
| 665 | testing::StopTiming(); |
| 666 | const GraphDef graph_def = |
| 667 | test::CreateGraphDef(num_nodes, num_edges_per_node); |
| 668 | Graph graph(OpRegistry::Global()); |
| 669 | GraphConstructorOptions opts; |
| 670 | TF_CHECK_OK(ConvertGraphDefToGraph(opts, graph_def, &graph)); |
| 671 | |
| 672 | int64 sum = 0; |
| 673 | testing::StartTiming(); |
| 674 | for (int i = 0; i < iters; ++i) { |
| 675 | for (const Node* node : graph.nodes()) { |
| 676 | for (auto e : node->in_edges()) { |
| 677 | sum += e->id(); |
| 678 | } |
| 679 | } |
| 680 | } |
| 681 | VLOG(1) << sum; |
| 682 | testing::StopTiming(); |
| 683 | } |
| 684 | BENCHMARK(BM_InEdgeIteration)->ArgPair(10, 2); |
| 685 | BENCHMARK(BM_InEdgeIteration)->ArgPair(1 << 6, 2); |
| 686 | BENCHMARK(BM_InEdgeIteration)->ArgPair(1 << 9, 2); |
nothing calls this directly
no test coverage detected