Skip to content

Commit 85c2766

Browse files
committed
Added benchmarks for other OSes / compilers
1 parent 542295e commit 85c2766

File tree

1 file changed

+41
-12
lines changed

1 file changed

+41
-12
lines changed

README.md

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,10 @@ Notes:
122122

123123
## Speed benchmarks
124124

125-
Labels are the same as in the comparison spreadsheet. The speed benchmarks were compiled with gcc 9.3.0 and libstdc++, with all optimizations turned on (except LTO), and run on a linux (5.1.0-89) machine with a Ryzen 5 2600 CPU. Speed is measured relative to `std::unique_ptr<T>` used as owner pointer, and `T*` used as observer pointer, which should be the fastest possible implementation (but obviously the one with least safety).
125+
Labels are the same as in the comparison spreadsheet. The speed benchmarks were compiled with all optimizations turned on (except LTO). Speed is measured relative to `std::unique_ptr<T>` used as owner pointer, and `T*` used as observer pointer, which should be the fastest possible implementation (but obviously the one with least safety).
126126

127127
You can run the benchmarks yourself, they are located in `tests/speed_benchmark.cpp`. The benchmark executable runs tests for three object types: `int`, `float`, `std::string`, and `std::array<int,65'536>`, to simulate objects of various allocation cost. The timings below are the worst-case values measured across all object types, which should be most relevant to highlight the overhead from the pointer itself (and erases flukes from the benchmarking framework). In real life scenarios, the actual measured overhead will be substantially lower, as actual business logic is likely to dominate the time budget.
128128

129-
| Pointer | raw/unique | weak/shared | observer/obs_unique | observer/obs_sealed |
130-
|--------------------------|------------|-------------|---------------------|---------------------|
131-
| Create owner empty | 1 | 1.1 | 1.1 | 1.1 |
132-
| Create owner | 1 | 2.2 | 1.9 | N/A |
133-
| Create owner factory | 1 | 1.3 | 1.8 | 1.3 |
134-
| Dereference owner | 1 | 1 | 1 | 1 |
135-
| Create observer empty | 1 | 1.2 | 1.2 | 1.3 |
136-
| Create observer | 1 | 1.5 | 1.6 | 1.6 |
137-
| Create observer copy | 1 | 1.7 | 1.7 | 1.7 |
138-
| Dereference observer | 1 | 4.8 | 1.2 | 1.3 |
139-
140129
Detail of the benchmarks:
141130
- Create owner empty: default-construct an owner pointer (to nullptr).
142131
- Create owner: construct an owner pointer by taking ownership of an existing object.
@@ -147,6 +136,46 @@ Detail of the benchmarks:
147136
- Create observer copy: construct a new observer pointer from another observer pointer.
148137
- Dereference observer: get a reference to the underlying object from an observer pointer.
149138

139+
*Compiler: gcc 9.3.0, std: libstdc++, OS: linux 5.1.0, CPU: Ryzen 5 2600:*
140+
141+
| Pointer | raw/unique | weak/shared | observer/obs_unique | observer/obs_sealed |
142+
|--------------------------|------------|-------------|---------------------|---------------------|
143+
| Create owner empty | 1 | 1.1 | 1.1 | 1.1 |
144+
| Create owner | 1 | 2.2 | 1.9 | N/A |
145+
| Create owner factory | 1 | 1.3 | 1.8 | 1.3 |
146+
| Dereference owner | 1 | 1 | 1 | 1 |
147+
| Create observer empty | 1 | 1.2 | 1.2 | 1.3 |
148+
| Create observer | 1 | 1.5 | 1.6 | 1.6 |
149+
| Create observer copy | 1 | 1.7 | 1.7 | 1.7 |
150+
| Dereference observer | 1 | 4.8 | 1.2 | 1.3 |
151+
152+
*Compiler: MSVC 16.11.3, std: MS-STL, OS: Windows 10.0.19043, CPU: i7-7800x:*
153+
154+
| Pointer | raw/unique | weak/shared | observer/obs_unique | observer/obs_sealed |
155+
|--------------------------|------------|-------------|---------------------|---------------------|
156+
| Create owner empty | 1 | 1.1 | 1.1 | 1.1 |
157+
| Create owner | 1 | 2.2 | 2.0 | N/A |
158+
| Create owner factory | 1 | 1.3 | 2.0 | 1.4 |
159+
| Dereference owner | 1 | 0.8 | 1.8 | 1.5 |
160+
| Create observer empty | 1 | 1.1 | 1.2 | 1.2 |
161+
| Create observer | 1 | 5.6 | 1.5 | 1.3 |
162+
| Create observer copy | 1 | 6.2 | 1.4 | 1.3 |
163+
| Dereference observer | 1 | 11 | 1.5 | 1.1 |
164+
165+
*Compiler: Emscripten 2.0.16, std: libc++, OS: Node.js 14.15.5 + linux kernel 5.1.0, CPU: Ryzen 5 2600:*
166+
167+
| Pointer | raw/unique | weak/shared | observer/obs_unique | observer/obs_sealed |
168+
|--------------------------|------------|-------------|---------------------|---------------------|
169+
| Create owner empty | 1 | 20 | 1.2 | 1 |
170+
| Create owner | 1 | 1.6 | 1.6 | N/A |
171+
| Create owner factory | 1 | 1.1 | 1.6 | 1 |
172+
| Dereference owner | 1 | 1 | 1 | 1 |
173+
| Create observer empty | 1 | 35 | 1.8 | 1.7 |
174+
| Create observer | 1 | 36 | 2.4 | 2.5 |
175+
| Create observer copy | 1 | 41 | 2.3 | 2.3 |
176+
| Dereference observer | 1 | 114 | 1 | 1 |
177+
178+
150179

151180
## Notes
152181

0 commit comments

Comments
 (0)