MCPcopy Create free account
hub / github.com/chronoxor/CppBenchmark / Run

Method Run

examples/sort.cpp:182–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180
181protected:
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
202class ShellSort : public CppBenchmark::Benchmark, public SortFixture

Callers

nothing calls this directly

Calls 2

AddItemsMethod · 0.80
swapFunction · 0.50

Tested by

no test coverage detected