You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Quickstart.md
+37-1Lines changed: 37 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -164,6 +164,40 @@ Almost any sorter can be passed to any adapter, with a few exceptions:
164
164
165
165
The specific restrictions are all documented in the adapters descriptions.
166
166
167
+
## Metrics
168
+
169
+
[Metrics][metrics] are a special kind of sorter adapters that can be used to retrieve information about about, such as the number of comparisons performed by a sorter, or the time it took to sort a collection. They are used together with the [metrics tools][metrics-tools] from the library utilities.
170
+
171
+
* Count the number of comparisons performed by a comparison sort:
172
+
```cpp
173
+
#include<vector>
174
+
#include<cpp-sort/metrics/comparisons.h>
175
+
#include<cpp-sort/sorters/slab_sorter.h>
176
+
177
+
intmain()
178
+
{
179
+
auto sorter = cppsort::metrics::comparisons<cppsort::slab_sorter>{};
auto sorter = cppsort::metrics::running_time<cppsort::mel_sorter>{};
195
+
std::vector<int> collection = { /* ... */ };
196
+
auto comps = sorter(collection);
197
+
std::print("melsort took {}", comps.value());
198
+
}
199
+
```
200
+
167
201
## Two-step sorting
168
202
169
203
Sometimes the information is not represented as simple collection of class instances, but as [parallel arrays][parallel-arrays] (also known as structure of arrays). To sort those, **cpp-sort** provides components for two-step sorting of random-access collections:
@@ -212,8 +246,10 @@ The previous sections describe some of the main tools provided by **cpp-sort** b
0 commit comments