github.com/swiftstack/proxyfs@v0.0.0-20201223034610-5434d919416e/evtlog/benchmark_test.go (about) 1 package evtlog 2 3 import ( 4 "testing" 5 6 "github.com/swiftstack/ProxyFS/conf" 7 "github.com/swiftstack/ProxyFS/transitions" 8 ) 9 10 var ( 11 benchmarkConfMap conf.ConfMap 12 ) 13 14 func benchmarkSetup(b *testing.B, enable bool) { 15 var ( 16 benchmarkConfMapStrings []string 17 err error 18 ) 19 20 if enable { 21 benchmarkConfMapStrings = []string{ 22 "Logging.LogFilePath=/dev/null", 23 "Logging.TraceLevelLogging=none", 24 "Logging.DebugLevelLogging=none", 25 "Logging.LogToConsole=false", 26 "Cluster.WhoAmI=nobody", 27 "FSGlobals.VolumeGroupList=", 28 "FSGlobals.CheckpointHeaderConsensusAttempts=5", 29 "FSGlobals.MountRetryLimit=6", 30 "FSGlobals.MountRetryDelay=1s", 31 "FSGlobals.MountRetryExpBackoff=2", 32 "FSGlobals.LogCheckpointHeaderPosts=true", 33 "FSGlobals.TryLockBackoffMin=10ms", 34 "FSGlobals.TryLockBackoffMax=50ms", 35 "FSGlobals.TryLockSerializationThreshhold=5", 36 "FSGlobals.SymlinkMax=32", 37 "FSGlobals.CoalesceElementChunkSize=16", 38 "EventLog.Enabled=true", 39 "EventLog.BufferKey=1234", 40 "EventLog.BufferLength=65536", //64KiB 41 "EventLog.MinBackoff=1us", 42 "EventLog.MaxBackoff=2us", 43 } 44 } else { 45 benchmarkConfMapStrings = []string{ 46 "Logging.LogFilePath=/dev/null", 47 "Logging.TraceLevelLogging=none", 48 "Logging.DebugLevelLogging=none", 49 "Logging.LogToConsole=false", 50 "Cluster.WhoAmI=nobody", 51 "FSGlobals.VolumeGroupList=", 52 "FSGlobals.CheckpointHeaderConsensusAttempts=5", 53 "FSGlobals.MountRetryLimit=6", 54 "FSGlobals.MountRetryDelay=1s", 55 "FSGlobals.MountRetryExpBackoff=2", 56 "FSGlobals.LogCheckpointHeaderPosts=true", 57 "FSGlobals.TryLockBackoffMin=10ms", 58 "FSGlobals.TryLockBackoffMax=50ms", 59 "FSGlobals.TryLockSerializationThreshhold=5", 60 "FSGlobals.SymlinkMax=32", 61 "FSGlobals.CoalesceElementChunkSize=16", 62 "EventLog.Enabled=false", 63 } 64 } 65 66 benchmarkConfMap, err = conf.MakeConfMapFromStrings(benchmarkConfMapStrings) 67 if nil != err { 68 b.Fatal(err) 69 } 70 71 err = transitions.Up(benchmarkConfMap) 72 if nil != err { 73 b.Fatal(err) 74 } 75 76 MarkForDeletion() 77 } 78 79 func benchmarkTeardown(b *testing.B) { 80 var ( 81 err error 82 ) 83 84 err = transitions.Down(benchmarkConfMap) 85 if nil != err { 86 b.Fatal(err) 87 } 88 } 89 90 func Benchmark1KRecordTestPatternFixedWhileDisabled(b *testing.B) { 91 benchmarkSetup(b, false) 92 b.ResetTimer() 93 for i := 0; i < b.N; i++ { 94 for j := 0; j < 1000; j++ { 95 Record(FormatTestPatternFixed) 96 } 97 } 98 b.StopTimer() 99 benchmarkTeardown(b) 100 } 101 102 func Benchmark1KRecordTestPatternSWhileDisabled(b *testing.B) { 103 benchmarkSetup(b, false) 104 b.ResetTimer() 105 for i := 0; i < b.N; i++ { 106 for j := 0; j < 1000; j++ { 107 Record(FormatTestPatternS, "arg0") 108 } 109 } 110 b.StopTimer() 111 benchmarkTeardown(b) 112 } 113 114 func Benchmark1KRecordTestPatternS03DWhileDisabled(b *testing.B) { 115 benchmarkSetup(b, false) 116 b.ResetTimer() 117 for i := 0; i < b.N; i++ { 118 for j := 0; j < 1000; j++ { 119 Record(FormatTestPatternS03D, "arg0", uint32(1)) 120 } 121 } 122 b.StopTimer() 123 benchmarkTeardown(b) 124 } 125 126 func Benchmark1KRecordTestPatternS08XWhileDisabled(b *testing.B) { 127 benchmarkSetup(b, false) 128 b.ResetTimer() 129 for i := 0; i < b.N; i++ { 130 for j := 0; j < 1000; j++ { 131 Record(FormatTestPatternS03D, "arg0", uint32(1)) 132 } 133 } 134 b.StopTimer() 135 benchmarkTeardown(b) 136 } 137 138 func Benchmark1KRecordTestPatternS016XWhileDisabled(b *testing.B) { 139 benchmarkSetup(b, false) 140 b.ResetTimer() 141 for i := 0; i < b.N; i++ { 142 for j := 0; j < 1000; j++ { 143 Record(FormatTestPatternS016X, "arg0", uint64(1)) 144 } 145 } 146 b.StopTimer() 147 benchmarkTeardown(b) 148 } 149 150 func Benchmark1KRecordTestPatternS016X016XWhileDisabled(b *testing.B) { 151 benchmarkSetup(b, false) 152 b.ResetTimer() 153 for i := 0; i < b.N; i++ { 154 for j := 0; j < 1000; j++ { 155 Record(FormatTestPatternS016X016X, "arg0", uint64(1), uint64(2)) 156 } 157 } 158 b.StopTimer() 159 benchmarkTeardown(b) 160 } 161 162 func Benchmark1KRecordTestPatternS016XsliceWhileDisabled(b *testing.B) { 163 benchmarkSetup(b, false) 164 b.ResetTimer() 165 for i := 0; i < b.N; i++ { 166 for j := 0; j < 1000; j++ { 167 Record(FormatTestPatternS016Xslice, "arg0", []uint64{uint64(0x101), uint64(0x102), uint64(0x103)}) 168 } 169 } 170 b.StopTimer() 171 benchmarkTeardown(b) 172 } 173 174 func Benchmark1KRecordTestPatternS016XSWhileDisabled(b *testing.B) { 175 benchmarkSetup(b, false) 176 b.ResetTimer() 177 for i := 0; i < b.N; i++ { 178 for j := 0; j < 1000; j++ { 179 Record(FormatTestPatternS016XS, "arg0", uint64(1), "arg..2") 180 } 181 } 182 b.StopTimer() 183 benchmarkTeardown(b) 184 } 185 186 func Benchmark1KRecordTestPatternSSWhileDisabled(b *testing.B) { 187 benchmarkSetup(b, false) 188 b.ResetTimer() 189 for i := 0; i < b.N; i++ { 190 for j := 0; j < 1000; j++ { 191 Record(FormatTestPatternSS, "arg0", "arg.1") 192 } 193 } 194 b.StopTimer() 195 benchmarkTeardown(b) 196 } 197 198 func Benchmark1KRecordTestPatternSS03DWhileDisabled(b *testing.B) { 199 benchmarkSetup(b, false) 200 b.ResetTimer() 201 for i := 0; i < b.N; i++ { 202 for j := 0; j < 1000; j++ { 203 Record(FormatTestPatternSS03D, "arg0", "arg.1", uint32(2)) 204 } 205 } 206 b.StopTimer() 207 benchmarkTeardown(b) 208 } 209 210 func Benchmark1KRecordTestPatternSSSWhileDisabled(b *testing.B) { 211 benchmarkSetup(b, false) 212 b.ResetTimer() 213 for i := 0; i < b.N; i++ { 214 for j := 0; j < 1000; j++ { 215 Record(FormatTestPatternSSS, "arg0", "arg.1", "arg..2") 216 } 217 } 218 b.StopTimer() 219 benchmarkTeardown(b) 220 } 221 222 func Benchmark1KRecordTestPatternSSS03DWhileDisabled(b *testing.B) { 223 benchmarkSetup(b, false) 224 b.ResetTimer() 225 for i := 0; i < b.N; i++ { 226 for j := 0; j < 1000; j++ { 227 Record(FormatTestPatternSSS03D, "arg0", "arg.1", "arg..2", uint32(3)) 228 } 229 } 230 b.StopTimer() 231 benchmarkTeardown(b) 232 } 233 234 func Benchmark1KRecordTestPatternSSS016X03DWhileDisabled(b *testing.B) { 235 benchmarkSetup(b, false) 236 b.ResetTimer() 237 for i := 0; i < b.N; i++ { 238 for j := 0; j < 1000; j++ { 239 Record(FormatTestPatternSSS016X03D, "arg0", "arg.1", "arg..2", uint64(3), uint32(4)) 240 } 241 } 242 b.StopTimer() 243 benchmarkTeardown(b) 244 } 245 246 func Benchmark1KRecordTestPatternFixedWhileEnabled(b *testing.B) { 247 benchmarkSetup(b, false) 248 b.ResetTimer() 249 for i := 0; i < b.N; i++ { 250 for j := 0; j < 1000; j++ { 251 Record(FormatTestPatternFixed) 252 } 253 } 254 b.StopTimer() 255 benchmarkTeardown(b) 256 } 257 258 func Benchmark1KRecordTestPatternSWhileEnabled(b *testing.B) { 259 benchmarkSetup(b, true) 260 b.ResetTimer() 261 for i := 0; i < b.N; i++ { 262 for j := 0; j < 1000; j++ { 263 Record(FormatTestPatternS, "arg0") 264 } 265 } 266 b.StopTimer() 267 benchmarkTeardown(b) 268 } 269 270 func Benchmark1KRecordTestPatternS03DWhileEnabled(b *testing.B) { 271 benchmarkSetup(b, true) 272 b.ResetTimer() 273 for i := 0; i < b.N; i++ { 274 for j := 0; j < 1000; j++ { 275 Record(FormatTestPatternS03D, "arg0", uint32(1)) 276 } 277 } 278 b.StopTimer() 279 benchmarkTeardown(b) 280 } 281 282 func Benchmark1KRecordTestPatternS08XWhileEnabled(b *testing.B) { 283 benchmarkSetup(b, true) 284 b.ResetTimer() 285 for i := 0; i < b.N; i++ { 286 for j := 0; j < 1000; j++ { 287 Record(FormatTestPatternS03D, "arg0", uint32(1)) 288 } 289 } 290 b.StopTimer() 291 benchmarkTeardown(b) 292 } 293 294 func Benchmark1KRecordTestPatternS016XWhileEnabled(b *testing.B) { 295 benchmarkSetup(b, true) 296 b.ResetTimer() 297 for i := 0; i < b.N; i++ { 298 for j := 0; j < 1000; j++ { 299 Record(FormatTestPatternS016X, "arg0", uint64(1)) 300 } 301 } 302 b.StopTimer() 303 benchmarkTeardown(b) 304 } 305 306 func Benchmark1KRecordTestPatternS016X016XWhileEnabled(b *testing.B) { 307 benchmarkSetup(b, true) 308 b.ResetTimer() 309 for i := 0; i < b.N; i++ { 310 for j := 0; j < 1000; j++ { 311 Record(FormatTestPatternS016X016X, "arg0", uint64(1), uint64(2)) 312 } 313 } 314 b.StopTimer() 315 benchmarkTeardown(b) 316 } 317 318 func Benchmark1KRecordTestPatternS016XsliceWhileEnabled(b *testing.B) { 319 benchmarkSetup(b, true) 320 b.ResetTimer() 321 for i := 0; i < b.N; i++ { 322 for j := 0; j < 1000; j++ { 323 Record(FormatTestPatternS016Xslice, "arg0", []uint64{uint64(0x101), uint64(0x102), uint64(0x103)}) 324 } 325 } 326 b.StopTimer() 327 benchmarkTeardown(b) 328 } 329 330 func Benchmark1KRecordTestPatternS016XSWhileEnabled(b *testing.B) { 331 benchmarkSetup(b, true) 332 b.ResetTimer() 333 for i := 0; i < b.N; i++ { 334 for j := 0; j < 1000; j++ { 335 Record(FormatTestPatternS016XS, "arg0", uint64(1), "arg..2") 336 } 337 } 338 b.StopTimer() 339 benchmarkTeardown(b) 340 } 341 342 func Benchmark1KRecordTestPatternSSWhileEnabled(b *testing.B) { 343 benchmarkSetup(b, true) 344 b.ResetTimer() 345 for i := 0; i < b.N; i++ { 346 for j := 0; j < 1000; j++ { 347 Record(FormatTestPatternSS, "arg0", "arg.1") 348 } 349 } 350 b.StopTimer() 351 benchmarkTeardown(b) 352 } 353 354 func Benchmark1KRecordTestPatternSS03DWhileEnabled(b *testing.B) { 355 benchmarkSetup(b, true) 356 b.ResetTimer() 357 for i := 0; i < b.N; i++ { 358 for j := 0; j < 1000; j++ { 359 Record(FormatTestPatternSS03D, "arg0", "arg.1", uint32(2)) 360 } 361 } 362 b.StopTimer() 363 benchmarkTeardown(b) 364 } 365 366 func Benchmark1KRecordTestPatternSSSWhileEnabled(b *testing.B) { 367 benchmarkSetup(b, true) 368 b.ResetTimer() 369 for i := 0; i < b.N; i++ { 370 for j := 0; j < 1000; j++ { 371 Record(FormatTestPatternSSS, "arg0", "arg.1", "arg..2") 372 } 373 } 374 b.StopTimer() 375 benchmarkTeardown(b) 376 } 377 378 func Benchmark1KRecordTestPatternSSS03DWhileEnabled(b *testing.B) { 379 benchmarkSetup(b, true) 380 b.ResetTimer() 381 for i := 0; i < b.N; i++ { 382 for j := 0; j < 1000; j++ { 383 Record(FormatTestPatternSSS03D, "arg0", "arg.1", "arg..2", uint32(3)) 384 } 385 } 386 b.StopTimer() 387 benchmarkTeardown(b) 388 } 389 390 func Benchmark1KRecordTestPatternSSS016X03DWhileEnabled(b *testing.B) { 391 benchmarkSetup(b, true) 392 b.ResetTimer() 393 for i := 0; i < b.N; i++ { 394 for j := 0; j < 1000; j++ { 395 Record(FormatTestPatternSSS016X03D, "arg0", "arg.1", "arg..2", uint64(3), uint32(4)) 396 } 397 } 398 b.StopTimer() 399 benchmarkTeardown(b) 400 }