@@ -41,27 +41,33 @@ let benchmarks = {
41
41
AA ( a: 2.4 , b: 2.4 ) ,
42
42
]
43
43
44
- let metrics : [ BenchmarkMetric ] = [ . cpuTotal, . wallClock, . mallocCountTotal, . releaseCount, . peakMemoryResident]
44
+ let metrics : [ BenchmarkMetric ] = [
45
+ . cpuTotal,
46
+ . wallClock,
47
+ . mallocCountTotal,
48
+ . releaseCount,
49
+ . peakMemoryResident,
50
+ ]
45
51
let maxIterations = 1_000_000
46
52
let maxDuration : Duration = . seconds( 3 )
47
53
let singleConfiguration : Benchmark . Configuration = . init(
48
- metrics: metrics,
49
- warmupIterations: 1 ,
50
- scalingFactor: . one,
51
- maxDuration: maxDuration,
52
- maxIterations: maxIterations)
54
+ metrics: metrics,
55
+ warmupIterations: 1 ,
56
+ scalingFactor: . one,
57
+ maxDuration: maxDuration,
58
+ maxIterations: maxIterations)
53
59
let kiloConfiguration : Benchmark . Configuration = . init(
54
- metrics: metrics,
55
- warmupIterations: 1 ,
56
- scalingFactor: . kilo,
57
- maxDuration: maxDuration,
58
- maxIterations: maxIterations)
60
+ metrics: metrics,
61
+ warmupIterations: 1 ,
62
+ scalingFactor: . kilo,
63
+ maxDuration: maxDuration,
64
+ maxIterations: maxIterations)
59
65
let megaConfiguration : Benchmark . Configuration = . init(
60
- metrics: metrics,
61
- warmupIterations: 1 ,
62
- scalingFactor: . mega,
63
- maxDuration: maxDuration,
64
- maxIterations: maxIterations)
66
+ metrics: metrics,
67
+ warmupIterations: 1 ,
68
+ scalingFactor: . mega,
69
+ maxDuration: maxDuration,
70
+ maxIterations: maxIterations)
65
71
66
72
Benchmark . defaultConfiguration = megaConfiguration
67
73
@@ -71,63 +77,74 @@ let benchmarks = {
71
77
}
72
78
}
73
79
80
+ Benchmark ( " Clearing 1GB " , configuration: singleConfiguration) { benchmark in
81
+ var fb = FlatBufferBuilder ( initialSize: 1_024_000_000 )
82
+ benchmark. startMeasurement ( )
83
+ for _ in benchmark. scaledIterations {
84
+ blackHole ( fb. clear ( ) )
85
+ }
86
+ }
87
+
74
88
Benchmark ( " Strings 10 " ) { benchmark in
75
89
var fb = FlatBufferBuilder ( initialSize: 1 <<20 )
76
90
benchmark. startMeasurement ( )
77
91
for _ in benchmark. scaledIterations {
78
- blackHole ( fb. create ( string: str10) )
92
+ blackHole ( fb. create ( string: str10) )
79
93
}
80
94
}
81
95
82
96
Benchmark ( " Strings 100 " ) { benchmark in
83
97
var fb = FlatBufferBuilder ( initialSize: 1 <<20 )
84
98
benchmark. startMeasurement ( )
85
99
for _ in benchmark. scaledIterations {
86
- blackHole ( fb. create ( string: str100) )
100
+ blackHole ( fb. create ( string: str100) )
87
101
}
88
102
}
89
103
90
104
Benchmark ( " Vector 1 Bytes " ) { benchmark in
91
105
var fb = FlatBufferBuilder ( initialSize: 1 <<20 )
92
106
benchmark. startMeasurement ( )
93
107
for _ in benchmark. scaledIterations {
94
- blackHole ( fb. createVector ( bytes: bytes) )
108
+ blackHole ( fb. createVector ( bytes: bytes) )
95
109
}
96
110
}
97
111
98
112
Benchmark ( " Vector 1 Ints " ) { benchmark in
99
113
var fb = FlatBufferBuilder ( initialSize: 1 <<20 )
100
114
benchmark. startMeasurement ( )
101
115
for _ in benchmark. scaledIterations {
102
- blackHole ( fb. createVector ( ints) )
116
+ blackHole ( fb. createVector ( ints) )
103
117
}
104
118
}
105
119
106
120
Benchmark ( " Vector 100 Ints " ) { benchmark in
107
121
var fb = FlatBufferBuilder ( initialSize: 1 <<20 )
108
122
benchmark. startMeasurement ( )
109
123
for i in benchmark. scaledIterations {
110
- blackHole ( fb. createVector ( ints) )
124
+ blackHole ( fb. createVector ( ints) )
111
125
}
112
126
}
113
127
114
128
Benchmark ( " Vector 100 Bytes " ) { benchmark in
115
129
var fb = FlatBufferBuilder ( initialSize: 1 <<20 )
116
130
benchmark. startMeasurement ( )
117
131
for i in benchmark. scaledIterations {
118
- blackHole ( fb. createVector ( bytes) )
132
+ blackHole ( fb. createVector ( bytes) )
119
133
}
120
134
}
121
135
122
136
Benchmark ( " Vector 100 ContiguousBytes " ) { benchmark in
123
137
var fb = FlatBufferBuilder ( initialSize: 1 <<20 )
124
138
benchmark. startMeasurement ( )
125
139
for i in benchmark. scaledIterations {
126
- blackHole ( fb. createVector ( bytes: bytes) )
140
+ blackHole ( fb. createVector ( bytes: bytes) )
127
141
}
128
142
}
129
143
130
- Benchmark ( " FlatBufferBuilder Add " , configuration: kiloConfiguration) { benchmark in
144
+ Benchmark (
145
+ " FlatBufferBuilder Add " ,
146
+ configuration: kiloConfiguration)
147
+ { benchmark in
131
148
var fb = FlatBufferBuilder ( initialSize: 1024 * 1024 * 32 )
132
149
benchmark. startMeasurement ( )
133
150
for _ in benchmark. scaledIterations {
@@ -148,11 +165,11 @@ let benchmarks = {
148
165
149
166
benchmark. startMeasurement ( )
150
167
for _ in benchmark. scaledIterations {
151
- let vector = fb. createVector (
152
- ofStructs: array)
153
- let start = fb. startTable ( with: 1 )
154
- fb. add ( offset: vector, at: 4 )
155
- offsets. append ( Offset ( offset: fb. endTable ( at: start) ) )
168
+ let vector = fb. createVector (
169
+ ofStructs: array)
170
+ let start = fb. startTable ( with: 1 )
171
+ fb. add ( offset: vector, at: 4 )
172
+ offsets. append ( Offset ( offset: fb. endTable ( at: start) ) )
156
173
}
157
174
158
175
let vector = fb. createVector ( ofOffsets: offsets)
0 commit comments