| 31 | namespace { |
| 32 | |
| 33 | auto uts(int depth, Node *parent) -> result { |
| 34 | |
| 35 | result r(depth, 1, 0); |
| 36 | |
| 37 | int num_children = uts_numChildren(parent); |
| 38 | int child_type = uts_childType(parent); |
| 39 | |
| 40 | parent->numChildren = num_children; |
| 41 | |
| 42 | if (num_children > 0) { |
| 43 | |
| 44 | std::vector<pair> cs(num_children); |
| 45 | |
| 46 | for (int i = 0; i < num_children; i++) { |
| 47 | |
| 48 | cs[i].child.type = child_type; |
| 49 | cs[i].child.height = parent->height + 1; |
| 50 | cs[i].child.numChildren = -1; // not yet determined |
| 51 | |
| 52 | for (int j = 0; j < computeGranularity; j++) { |
| 53 | rng_spawn(parent->state.state, cs[i].child.state.state, i); |
| 54 | } |
| 55 | |
| 56 | cs[i].res = uts(depth + 1, &cs[i].child); |
| 57 | } |
| 58 | |
| 59 | for (auto &&elem : cs) { |
| 60 | r.maxdepth = max(r.maxdepth, elem.res.maxdepth); |
| 61 | r.size += elem.res.size; |
| 62 | r.leaves += elem.res.leaves; |
| 63 | } |
| 64 | } else { |
| 65 | r.leaves = 1; |
| 66 | } |
| 67 | |
| 68 | // std::cout << "maxdepth: " << r.maxdepth << " size: " << r.size << " leaves: " << r.leaves << std::endl; |
| 69 | |
| 70 | return r; |
| 71 | } |
| 72 | |
| 73 | void uts_serial(benchmark::State &state, int tree) { |
| 74 |
no test coverage detected