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: README.md
+38Lines changed: 38 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -89,6 +89,44 @@ int main(int argc, char *argv[])
89
89
}
90
90
```
91
91
92
+
Benchmark
93
+
-------
94
+
We can observe speed ups for structure of arrays vs array of structs with the toy program benchmark.cc
95
+
Here are the results using Visual Studio 2022 on Release mode on my laptop.
96
+
97
+
```
98
+
benchmark results ==============
99
+
soa sort time 0.126592
100
+
vec sort time 0.312302
101
+
soa timestamp avg time 0.0018725
102
+
vec timestamp avg time 0.0052643
103
+
```
104
+
105
+
The benchmark contains a small program concerning simulated sensor measurements. With a straightforward array of structs, we store metadata together with the actual sensor data together and then just push_back() these onto an std::vector.
106
+
```c++
107
+
struct SensorData {
108
+
std::array<double, 18> xyz;
109
+
110
+
struct Measurement {
111
+
Id sensor_id;
112
+
Id object_id;
113
+
double timestamp;
114
+
SensorData data;
115
+
};
116
+
117
+
...
118
+
119
+
std::vector<Measurement> measurements_vec;
120
+
measurements_vec.push_back(m);
121
+
```
122
+
Alternatively, we could split the metadata and sensor data apart into a structure of arrays.
The benchmark times the cost of sorting by sensor_id, and then the cost of finding the average measurement timestamp using an std::vector vs a vapid::soa.
129
+
92
130
Manual Installation
93
131
-----------
94
132
Copy the vapid folder into your project and #include "vapid/soa.h"
0 commit comments