| 174 | }; |
| 175 | |
| 176 | class InsertSort : public CppBenchmark::Benchmark, public SortFixture |
| 177 | { |
| 178 | public: |
| 179 | using Benchmark::Benchmark; |
| 180 | |
| 181 | protected: |
| 182 | void Run(CppBenchmark::Context& context) override |
| 183 | { |
| 184 | // Generate items to sort |
| 185 | std::generate(items.begin(), items.end(), rand); |
| 186 | |
| 187 | // Sort items |
| 188 | for (size_t i = 1; i < items.size(); ++i) |
| 189 | { |
| 190 | // Take the next item |
| 191 | for (size_t j = i + 1; j > 1; --j) |
| 192 | { |
| 193 | // Check the current item with the previous one |
| 194 | if (items[j - 1] < items[j - 1 - 1]) |
| 195 | std::swap(items[j - 1], items[j - 1 - 1]); |
| 196 | } |
| 197 | } |
| 198 | context.metrics().AddItems(items.size()); |
| 199 | } |
| 200 | }; |
| 201 | |
| 202 | class ShellSort : public CppBenchmark::Benchmark, public SortFixture |
| 203 | { |
nothing calls this directly
no outgoing calls
no test coverage detected