├── .gitattributes ├── .githooks └── pre-push ├── .gitignore ├── .vscode ├── launch.json └── tasks.json ├── AzureServiceBus ├── AzureServiceBus.drawio.svg ├── BodyAfter.png ├── BodyBefore.png └── MSMQ.drawio.svg ├── HOOKS.md ├── LICENSE ├── PipelineOptimizations ├── .idea │ └── .idea.PipelineOptimizations.dir │ │ └── .idea │ │ ├── .gitignore │ │ ├── aws.xml │ │ ├── encodings.xml │ │ ├── indexLayout.xml │ │ └── vcs.xml ├── .vscode │ ├── launch.json │ └── tasks.json ├── FolderStructure.png ├── FolderStructureWithHighlights.png ├── Pipeline │ ├── BaseLineBehavior.cs │ ├── BaseLinePipeline.cs │ ├── Behavior.cs │ ├── BehaviorChain.cs │ ├── BehaviorContext.cs │ ├── BehaviorInstance.cs │ ├── BehaviorInvoker.cs │ ├── ContextBag.cs │ ├── Dependency.cs │ ├── IBehavior.cs │ ├── IBehaviorContext.cs │ ├── IBehaviorInvoker.cs │ ├── IBuilder.cs │ ├── IExtendable.cs │ ├── IPipelineTerminator.cs │ ├── IStageConnector.cs │ ├── PipelineModelBuilder.cs │ ├── PipelineModifications.cs │ ├── PipelineTerminator.cs │ ├── ReadOnlySettings.cs │ ├── RegisterStep.cs │ ├── RegisterStepExtensions.cs │ ├── RemoveStep.cs │ ├── ReplaceStep.cs │ ├── SettingsHolder.cs │ ├── StageConnector.cs │ └── StepRegistrationsCoordinator.cs ├── PipelineOptimizations.csproj ├── PipelineOptimizations.csproj.DotSettings ├── PipelineTests.png ├── Program.cs ├── Step1 │ ├── BehaviorExtensions.cs │ ├── BehaviorOptimization.cs │ ├── PipelineOptimization.cs │ ├── Step1_PipelineException.cs │ ├── Step1_PipelineExecution.cs │ └── Step1_PipelineWarmup.cs ├── Step2 │ ├── BehaviorExtensions.cs │ ├── ContextBag.cs │ ├── PipelineOptimization.cs │ ├── Step2_PipelineException.cs │ ├── Step2_PipelineExecution.cs │ └── Step2_PipelineWarmup.cs └── Step3 │ ├── BehaviorExtensions.cs │ ├── PipelineOptimization.cs │ ├── Step3_PipelineException.cs │ ├── Step3_PipelineExecution.cs │ └── Step3_PipelineWarmup.cs ├── PipelinePublishV6 ├── MyEvent.cs ├── MyEventHandler.cs ├── NServiceBus.svg ├── Pipeline.svg ├── PipelinePublishV6.csproj ├── PipelineV6BehaviorChainZoomIn.png ├── PipelineV6BehaviorChainZoomIn2.png ├── PipelineV6BehaviorChainZoomInOptimized.png ├── PipelineV6BehaviorZoomIn.png ├── PipelineV6PublishCpuOverview.png ├── PipelineV6PublishCpuOverviewFlamegraph.png ├── PipelineV6PublishCpuOverviewOptimizedFlamegraph.png ├── PipelineV6PublishCpuPerfViewFlamegraph.png ├── PipelineV6PublishMemoryOverview.png ├── PipelineV6PublishMemoryOverviewOptimized.png ├── PipelineV6ReceiveCpuOverview.png ├── PipelineV6ReceiveCpuOverviewFlamegraph.png ├── PipelineV6ReceiveCpuOverviewOptimizedFlamegraph.png ├── PipelineV6ReceiveCpuPerfViewFlamegraph.png ├── PipelineV6ReceiveMemoryOverview.png ├── PipelineV6ReceiveMemoryOverviewOptimized.png ├── PipelineV6StageForkAndDisplayClasses.png ├── PipelineV6StageForkAndDisplayClassesOptimized.png ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── README.md ├── Simple ├── Program.cs ├── Simple.csproj ├── StringJoin.cs └── ValueStringBuilder.cs ├── images ├── 053b96864557636a9d4433d47a715e02 ├── 0b94d81807e4f45e8a18b78aabbf842b.png ├── 1928349fd5404a17561f40017721c87b.svg ├── 19d975b350aaebbbfca0a89ad63802d6.png ├── 202b4689a8d7f41ddff962836c7c14a2.svg ├── 2526187f700b13dc833f74f3837c97a2.gif ├── 34389925f86fde6a2d8d861a9d82c0f0.png ├── 348e079793223114e33ffc101d4b78ef ├── 3753e4d0befe16ffa757d21e8a6ee624.png ├── 383a4c4e4d66b4be3501e8543c5f5c58.png ├── 3ec66a7441fbd06e36b18a3f305b6fd8 ├── 40a08f8157634e8024628f4faa578215.png ├── 50cc30602a667e6393392291adc842d9.svg ├── 56c42038c4b5aefc6858fe7f22201239.png ├── 5b976ee516b4bf1f21e77082c48075e2 ├── 5f4516cbce1b6216863d7e7f715176eb.jpg ├── 611f47a787199a4b307fa850a6799f66.png ├── 65dd44daffbd93cb0aa79054657d0fb6.png ├── 6bcab76360da0344e65f4d08a696706e.gif ├── 7e85e80a6c1c3add28e6563f9de0ee93.jpg ├── 8509e92cdec2f61f8b253f31bcdf4b20 ├── 8a9347042ced3a4d29a4534f1cd4cef7.gif ├── 8c801f6d3d8ed48e88b878868191b4dd.png ├── 8d775a6f7fa6f4a11375067c53a618bb.png ├── 8e3a27607012f78e399a6eaf90e57cd9.gif ├── 9614058d0ca65d9baea3e149d35db0f9.gif ├── 98cd3e80810f41626f293907a269c75d ├── 9aac330bd57a1ecfd0c90320968af3ce.gif ├── a7397e6e6bf45f949df6fb38ee262ff2.png ├── aa1d92385b8aca6d2a6e529a3912242d ├── ab2d29e1e882e268c01ab37febcf033b.png ├── ad50cf7dea44b686dcc0aeb85ad96b48.png ├── adfef2aa887b26c925132b77bad53cc8.svg ├── b16407686970500b8f14d9fc064a29f6 ├── b17cf7d9ae77288175395ad472bb0b0c ├── b69e2d887d50a17abec28a894d63641b.png ├── bcc35ca335328fc8edbd703aa452e2fe.png ├── bd90452a5153975854bda80fc2f74767.png ├── be2d7b2dbd167d401b3d0c2bc865072b.png ├── bf682c86a581d9d240d18972025c9b71.png ├── c29bf8f8a323c227ab5ea8a8d1b31472.gif ├── c49e53dc5aacc0806bda9ba2ff96302e ├── ca359274720dc037d1fcdc9f83d0195b.png ├── cb8825c23f5c49d80be4b641d43a3da9.png ├── d690b3fc2a94a1f83f9cdb9cf75bd80d.png ├── dc58df196a8a8efd1baffcfd03538f50.png ├── ecbc13bda83afc81f4a8b54ff346443c.svg ├── fa8524b6df89e3e7798dac000345b70b.png └── fc2b634e166d5e29b1ac1912bc331848 ├── index.html ├── lib ├── fonts │ ├── asul │ │ ├── asul-bold.woff │ │ ├── asul-regular.woff │ │ └── asul.css │ ├── cabinsketch │ │ ├── cabinsketch-bold.woff │ │ ├── cabinsketch-regular.woff │ │ └── cabinsketch.css │ ├── josefinsans │ │ ├── josefinsans-bold.woff │ │ ├── josefinsans-bolditalic.woff │ │ ├── josefinsans-italic.woff │ │ ├── josefinsans-regular.woff │ │ └── josefinsans.css │ ├── katex │ │ ├── KaTeX_AMS-Regular.woff │ │ ├── KaTeX_Caligraphic-Bold.woff │ │ ├── KaTeX_Caligraphic-Regular.woff │ │ ├── KaTeX_Fraktur-Bold.woff │ │ ├── KaTeX_Fraktur-Regular.woff │ │ ├── KaTeX_Main-Bold.woff │ │ ├── KaTeX_Main-BoldItalic.woff │ │ ├── KaTeX_Main-Italic.woff │ │ ├── KaTeX_Main-Regular.woff │ │ ├── KaTeX_Math-BoldItalic.woff │ │ ├── KaTeX_Math-Italic.woff │ │ ├── KaTeX_Math-Regular.woff │ │ ├── KaTeX_SansSerif-Bold.woff │ │ ├── KaTeX_SansSerif-Italic.woff │ │ ├── KaTeX_SansSerif-Regular.woff │ │ ├── KaTeX_Script-Regular.woff │ │ ├── KaTeX_Size1-Regular.woff │ │ ├── KaTeX_Size2-Regular.woff │ │ ├── KaTeX_Size3-Regular.woff │ │ ├── KaTeX_Size4-Regular.woff │ │ └── KaTeX_Typewriter-Regular.woff │ ├── lato │ │ ├── lato-bold.woff │ │ ├── lato-bolditalic.woff │ │ ├── lato-italic.woff │ │ ├── lato-regular.woff │ │ └── lato.css │ ├── league │ │ ├── league_gothic.css │ │ ├── league_gothic.woff │ │ └── league_gothic_license │ ├── merriweathersans │ │ ├── merriweathersans-bold.woff │ │ ├── merriweathersans-regular.woff │ │ └── merriweathersans.css │ ├── montserrat │ │ ├── montserrat-bold.woff │ │ ├── montserrat-regular.woff │ │ └── montserrat.css │ ├── newscycle │ │ ├── newscycle-bold.woff │ │ ├── newscycle-regular.woff │ │ └── newscycle.css │ ├── opensans │ │ ├── opensans-bold.woff │ │ ├── opensans-bolditalic.woff │ │ ├── opensans-italic.woff │ │ ├── opensans-regular.woff │ │ └── opensans.css │ ├── overpass │ │ ├── overpass-bold.woff │ │ ├── overpass-light.woff │ │ ├── overpass-regular.woff │ │ └── overpass.css │ ├── overpass2 │ │ ├── overpass2-bold.woff │ │ ├── overpass2-bolditalic.woff │ │ ├── overpass2-extralight.woff │ │ ├── overpass2-extralightitalic.woff │ │ ├── overpass2-italic.woff │ │ ├── overpass2-light.woff │ │ ├── overpass2-lightitalic.woff │ │ ├── overpass2-regular.woff │ │ └── overpass2.css │ ├── oxygen │ │ ├── oxygen-bold.woff │ │ ├── oxygen-regular.woff │ │ └── oxygen.css │ └── quicksand │ │ ├── quicksand-bold.woff │ │ ├── quicksand-regular.woff │ │ └── quicksand.css ├── offline-v1.css ├── offline-v2.css ├── offline.js ├── reveal-plugins.js ├── reveal.css └── reveal.js ├── logitech_spotlight_revealjs.json ├── slides.pdf └── slides.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # handle html things 5 | *.css text diff=css 6 | *.htm text diff=html 7 | *.html text diff=html 8 | -------------------------------------------------------------------------------- /.githooks/pre-push: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # drop this in .git/hooks/, and chmod +x .git/hooks/pre-push 3 | 4 | # store current branch 5 | cur_branch=$(git rev-parse --abbrev-ref HEAD) 6 | if [[ $cur_branch == "gh-pages" ]] 7 | then 8 | # bail out if we're trying to push the gh-pages branch (to prevent infinite loop) 9 | exit 0 10 | else 11 | # merge current branch into gh-pages 12 | git checkout gh-pages 13 | git merge -m 'automatic pre-push merge' $cur_branch 14 | # push gh-pages 15 | git push origin gh-pages 16 | # switch back and exit 17 | git checkout $cur_branch 18 | fi 19 | exit 0 20 | 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # ASP.NET Scaffolding 66 | ScaffoldingReadMe.txt 67 | 68 | # StyleCop 69 | StyleCopReport.xml 70 | 71 | # Files built by Visual Studio 72 | *_i.c 73 | *_p.c 74 | *_h.h 75 | *.ilk 76 | *.meta 77 | *.obj 78 | *.iobj 79 | *.pch 80 | *.pdb 81 | *.ipdb 82 | *.pgc 83 | *.pgd 84 | *.rsp 85 | *.sbr 86 | *.tlb 87 | *.tli 88 | *.tlh 89 | *.tmp 90 | *.tmp_proj 91 | *_wpftmp.csproj 92 | *.log 93 | *.tlog 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 298 | *.vbp 299 | 300 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 301 | *.dsw 302 | *.dsp 303 | 304 | # Visual Studio 6 technical files 305 | *.ncb 306 | *.aps 307 | 308 | # Visual Studio LightSwitch build output 309 | **/*.HTMLClient/GeneratedArtifacts 310 | **/*.DesktopClient/GeneratedArtifacts 311 | **/*.DesktopClient/ModelManifest.xml 312 | **/*.Server/GeneratedArtifacts 313 | **/*.Server/ModelManifest.xml 314 | _Pvt_Extensions 315 | 316 | # Paket dependency manager 317 | .paket/paket.exe 318 | paket-files/ 319 | 320 | # FAKE - F# Make 321 | .fake/ 322 | 323 | # CodeRush personal settings 324 | .cr/personal 325 | 326 | # Python Tools for Visual Studio (PTVS) 327 | __pycache__/ 328 | *.pyc 329 | 330 | # Cake - Uncomment if you are using it 331 | # tools/** 332 | # !tools/packages.config 333 | 334 | # Tabs Studio 335 | *.tss 336 | 337 | # Telerik's JustMock configuration file 338 | *.jmconfig 339 | 340 | # BizTalk build output 341 | *.btp.cs 342 | *.btm.cs 343 | *.odx.cs 344 | *.xsd.cs 345 | 346 | # OpenCover UI analysis results 347 | OpenCover/ 348 | 349 | # Azure Stream Analytics local run output 350 | ASALocalRun/ 351 | 352 | # MSBuild Binary and Structured Log 353 | *.binlog 354 | 355 | # NVidia Nsight GPU debugger configuration file 356 | *.nvuser 357 | 358 | # MFractors (Xamarin productivity tool) working folder 359 | .mfractor/ 360 | 361 | # Local History for Visual Studio 362 | .localhistory/ 363 | 364 | # Visual Studio History (VSHistory) files 365 | .vshistory/ 366 | 367 | # BeatPulse healthcheck temp database 368 | healthchecksdb 369 | 370 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 371 | MigrationBackup/ 372 | 373 | # Ionide (cross platform F# VS Code tools) working folder 374 | .ionide/ 375 | 376 | # Fody - auto-generated XML schema 377 | FodyWeavers.xsd 378 | 379 | # VS Code files for those working on multiple tools 380 | .vscode/* 381 | !.vscode/settings.json 382 | !.vscode/tasks.json 383 | !.vscode/launch.json 384 | !.vscode/extensions.json 385 | *.code-workspace 386 | 387 | # Local History for Visual Studio Code 388 | .history/ 389 | 390 | # Windows Installer files from build outputs 391 | *.cab 392 | *.msi 393 | *.msix 394 | *.msm 395 | *.msp 396 | 397 | # JetBrains Rider 398 | *.sln.iml 399 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | // Use IntelliSense to find out which attributes exist for C# debugging 6 | // Use hover for the description of the existing attributes 7 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/PipelineOptimizations/bin/Debug/net7.0/PipelineOptimizations.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}/PipelineOptimizations", 16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 17 | "console": "internalConsole", 18 | "stopAtEntry": false 19 | }, 20 | { 21 | "name": ".NET Core Attach", 22 | "type": "coreclr", 23 | "request": "attach" 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/PipelineOptimizations/PipelineOptimizations.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/PipelineOptimizations/PipelineOptimizations.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "--project", 36 | "${workspaceFolder}/PipelineOptimizations/PipelineOptimizations.csproj" 37 | ], 38 | "problemMatcher": "$msCompile" 39 | } 40 | ] 41 | } -------------------------------------------------------------------------------- /AzureServiceBus/AzureServiceBus.drawio.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NServiceBus PipelineNServiceBus PipelineNServiceBus TransportNServiceBus TransportAzure.Messaging.ServiceBusAzure.Messaging.ServiceBusMicrosoft.Azure.AmqpMicrosoft.Azure.AmqpText is not SVG - cannot display -------------------------------------------------------------------------------- /AzureServiceBus/BodyAfter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/AzureServiceBus/BodyAfter.png -------------------------------------------------------------------------------- /AzureServiceBus/BodyBefore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/AzureServiceBus/BodyBefore.png -------------------------------------------------------------------------------- /AzureServiceBus/MSMQ.drawio.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NServiceBus PipelineNServiceBus PipelineNServiceBus TransportNServiceBus TransportMSMQMSMQText is not SVG - cannot display -------------------------------------------------------------------------------- /HOOKS.md: -------------------------------------------------------------------------------- 1 | git config --local core.hooksPath .githooks/ 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /PipelineOptimizations/.idea/.idea.PipelineOptimizations.dir/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Rider ignored files 5 | /projectSettingsUpdater.xml 6 | /contentModel.xml 7 | /.idea.PipelineOptimizations.iml 8 | /modules.xml 9 | # Editor-based HTTP Client requests 10 | /httpRequests/ 11 | # Datasource local storage ignored files 12 | /dataSources/ 13 | /dataSources.local.xml 14 | -------------------------------------------------------------------------------- /PipelineOptimizations/.idea/.idea.PipelineOptimizations.dir/.idea/aws.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /PipelineOptimizations/.idea/.idea.PipelineOptimizations.dir/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /PipelineOptimizations/.idea/.idea.PipelineOptimizations.dir/.idea/indexLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PipelineOptimizations/.idea/.idea.PipelineOptimizations.dir/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /PipelineOptimizations/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | // Use IntelliSense to find out which attributes exist for C# debugging 6 | // Use hover for the description of the existing attributes 7 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/net7.0/PipelineOptimizations.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 17 | "console": "internalConsole", 18 | "stopAtEntry": false 19 | }, 20 | { 21 | "name": ".NET Core Attach", 22 | "type": "coreclr", 23 | "request": "attach" 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /PipelineOptimizations/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/PipelineOptimizations.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/PipelineOptimizations.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "--project", 36 | "${workspaceFolder}/PipelineOptimizations.csproj" 37 | ], 38 | "problemMatcher": "$msCompile" 39 | } 40 | ] 41 | } -------------------------------------------------------------------------------- /PipelineOptimizations/FolderStructure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelineOptimizations/FolderStructure.png -------------------------------------------------------------------------------- /PipelineOptimizations/FolderStructureWithHighlights.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelineOptimizations/FolderStructureWithHighlights.png -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/BaseLineBehavior.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | public class BaseLineBehavior : Behavior 4 | { 5 | public override Task Invoke(IBehaviorContext context, Func next) 6 | { 7 | return next(); 8 | } 9 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/BaseLinePipeline.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | public class BaseLinePipeline 4 | where TContext : IBehaviorContext 5 | { 6 | public BaseLinePipeline(IBuilder builder, ReadOnlySettings settings, 7 | PipelineModifications pipelineModifications) 8 | { 9 | var coordinator = new StepRegistrationsCoordinator(pipelineModifications.Removals, 10 | pipelineModifications.Replacements); 11 | 12 | foreach (var rego in pipelineModifications.Additions.Where(x => x.IsEnabled(settings))) 13 | { 14 | coordinator.Register(rego); 15 | } 16 | 17 | behaviors = coordinator.BuildPipelineModelFor() 18 | .Select(r => r.CreateBehaviorOld(builder)).ToArray(); 19 | } 20 | 21 | public Task Invoke(TContext context) 22 | { 23 | var pipeline = new BehaviorChain(behaviors); 24 | return pipeline.Invoke(context); 25 | } 26 | 27 | BehaviorInstance[] behaviors; 28 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/Behavior.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | public abstract class Behavior : IBehavior where TContext : IBehaviorContext 4 | { 5 | public Task Invoke(TContext context, Func next) 6 | { 7 | return Invoke(context, () => next(context)); 8 | } 9 | 10 | public abstract Task Invoke(TContext context, Func next); 11 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/BehaviorChain.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | class BehaviorChain : IDisposable 4 | { 5 | public BehaviorChain(IEnumerable behaviorList) 6 | { 7 | itemDescriptors = behaviorList.ToArray(); 8 | } 9 | 10 | public void Dispose() 11 | { 12 | } 13 | 14 | public Task Invoke(IBehaviorContext context) 15 | { 16 | 17 | return InvokeNext(context, 0); 18 | } 19 | 20 | Task InvokeNext(IBehaviorContext context, int currentIndex) 21 | { 22 | if (currentIndex == itemDescriptors.Length) 23 | { 24 | return Task.CompletedTask; 25 | } 26 | 27 | var behavior = itemDescriptors[currentIndex]; 28 | 29 | return behavior.Invoke(context, newContext => InvokeNext(newContext, currentIndex + 1)); 30 | } 31 | 32 | BehaviorInstance[] itemDescriptors; 33 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/BehaviorContext.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | class BehaviorContext : ContextBag, IBehaviorContext 4 | { 5 | public ContextBag Extensions => this; 6 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/BehaviorInstance.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | class BehaviorInstance 4 | { 5 | public BehaviorInstance(Type behaviorType, IBehavior instance) 6 | { 7 | this.instance = instance; 8 | Type = behaviorType; 9 | invoker = CreateInvoker(Type); 10 | } 11 | 12 | public Type Type { get; } 13 | 14 | static IBehaviorInvoker CreateInvoker(Type type) 15 | { 16 | var behaviorInterface = 17 | type.GetInterfaces().First(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IBehavior<,>)); 18 | var invokerType = typeof(BehaviorInvoker<,>).MakeGenericType(behaviorInterface.GetGenericArguments()); 19 | return (IBehaviorInvoker) Activator.CreateInstance(invokerType); 20 | } 21 | 22 | public Task Invoke(IBehaviorContext context, Func next) 23 | { 24 | return invoker.Invoke(instance, context, next); 25 | } 26 | 27 | IBehavior instance; 28 | IBehaviorInvoker invoker; 29 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/BehaviorInvoker.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | class BehaviorInvoker : IBehaviorInvoker 4 | where TOut : IBehaviorContext 5 | where TIn : IBehaviorContext 6 | { 7 | public Task Invoke(object behavior, IBehaviorContext context, Func next) 8 | { 9 | return ((IBehavior) behavior).Invoke((TIn) context, next as Func); 10 | } 11 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/ContextBag.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | public partial class ContextBag 4 | { 5 | public ContextBag(ContextBag parentBag = null) 6 | { 7 | this.parentBag = parentBag; 8 | } 9 | 10 | public T Get() 11 | { 12 | return Get(typeof(T).FullName); 13 | } 14 | 15 | public bool TryGet(out T result) 16 | { 17 | return TryGet(typeof(T).FullName, out result); 18 | } 19 | 20 | public bool TryGet(string key, out T result) 21 | { 22 | if (stash.TryGetValue(key, out var value)) 23 | { 24 | result = (T)value; 25 | return true; 26 | } 27 | 28 | if (parentBag != null) 29 | { 30 | return parentBag.TryGet(key, out result); 31 | } 32 | 33 | result = default; 34 | return false; 35 | } 36 | 37 | public T Get(string key) 38 | { 39 | if (!TryGet(key, out T result)) 40 | { 41 | throw new KeyNotFoundException("No item found in behavior context with key: " + key); 42 | } 43 | 44 | return result; 45 | } 46 | 47 | public T GetOrCreate() where T : class, new() 48 | { 49 | if (TryGet(out T value)) 50 | { 51 | return value; 52 | } 53 | 54 | var newInstance = new T(); 55 | 56 | Set(newInstance); 57 | 58 | return newInstance; 59 | } 60 | 61 | public void Set(T t) 62 | { 63 | Set(typeof(T).FullName, t); 64 | } 65 | 66 | 67 | public void Remove() 68 | { 69 | Remove(typeof(T).FullName); 70 | } 71 | 72 | public void Remove(string key) 73 | { 74 | stash.Remove(key); 75 | } 76 | 77 | public void Set(string key, T t) 78 | { 79 | stash[key] = t; 80 | } 81 | 82 | internal void Merge(ContextBag context) 83 | { 84 | foreach (var kvp in context.stash) 85 | { 86 | stash[kvp.Key] = kvp.Value; 87 | } 88 | } 89 | 90 | ContextBag parentBag; 91 | 92 | Dictionary stash = new Dictionary(); 93 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/Dependency.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | class Dependency 4 | { 5 | public enum DependencyDirection 6 | { 7 | Before = 1, 8 | After = 2 9 | } 10 | 11 | public Dependency(string dependantId, string dependsOnId, DependencyDirection direction, bool enforce) 12 | { 13 | DependantId = dependantId; 14 | DependsOnId = dependsOnId; 15 | Direction = direction; 16 | Enforce = enforce; 17 | } 18 | 19 | public string DependantId { get; private set; } 20 | public string DependsOnId { get; private set; } 21 | public bool Enforce { get; private set; } 22 | 23 | public DependencyDirection Direction { get; private set; } 24 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/IBehavior.cs: -------------------------------------------------------------------------------- 1 | using NServiceBus.Pipeline; 2 | 3 | namespace NServiceBus.Pipeline; 4 | 5 | public interface IBehavior : IBehavior 6 | where TInContext : IBehaviorContext 7 | where TOutContext : IBehaviorContext 8 | { 9 | Task Invoke(TInContext context, Func next); 10 | } 11 | 12 | public interface IBehavior 13 | { 14 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/IBehaviorContext.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | public interface IBehaviorContext : IExtendable 4 | { 5 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/IBehaviorInvoker.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | interface IBehaviorInvoker 4 | { 5 | Task Invoke(object behavior, IBehaviorContext context, Func next); 6 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/IBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | public interface IBuilder : IDisposable 4 | { 5 | object Build(Type typeToBuild); 6 | 7 | IBuilder CreateChildBuilder(); 8 | 9 | T Build(); 10 | 11 | IEnumerable BuildAll(); 12 | 13 | IEnumerable BuildAll(Type typeToBuild); 14 | 15 | void Release(object instance); 16 | 17 | void BuildAndDispatch(Type typeToBuild, Action action); 18 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/IExtendable.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace NServiceBus.Pipeline; 4 | 5 | public interface IExtendable 6 | { 7 | /// 8 | /// A which can be used to extend the current object. 9 | /// 10 | [EditorBrowsable(EditorBrowsableState.Never)] 11 | ContextBag Extensions { get; } 12 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/IPipelineTerminator.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | interface IPipelineTerminator 4 | { 5 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/IStageConnector.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | interface IStageConnector 4 | { 5 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/PipelineModelBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | class PipelineModelBuilder 4 | { 5 | public PipelineModelBuilder(Type rootContextType, List additions, List removals, 6 | List replacements) 7 | { 8 | this.rootContextType = rootContextType; 9 | this.additions = additions; 10 | this.removals = removals; 11 | this.replacements = replacements; 12 | } 13 | 14 | public List Build() 15 | { 16 | var registrations = new Dictionary(StringComparer.CurrentCultureIgnoreCase); 17 | var listOfBeforeAndAfterIds = new List(); 18 | 19 | // Let's do some validation too 20 | 21 | //Step 1: validate that additions are unique 22 | foreach (var metadata in additions) 23 | { 24 | if (!registrations.ContainsKey(metadata.StepId)) 25 | { 26 | registrations.Add(metadata.StepId, metadata); 27 | if (metadata.Afters != null) 28 | { 29 | listOfBeforeAndAfterIds.AddRange(metadata.Afters.Select(a => a.DependsOnId)); 30 | } 31 | if (metadata.Befores != null) 32 | { 33 | listOfBeforeAndAfterIds.AddRange(metadata.Befores.Select(b => b.DependsOnId)); 34 | } 35 | 36 | continue; 37 | } 38 | 39 | var message = 40 | $"Step registration with id '{metadata.StepId}' is already registered for '{registrations[metadata.StepId].BehaviorType}'."; 41 | throw new Exception(message); 42 | } 43 | 44 | // Step 2: do replacements 45 | foreach (var metadata in replacements) 46 | { 47 | if (!registrations.ContainsKey(metadata.ReplaceId)) 48 | { 49 | var message = 50 | $"You can only replace an existing step registration, '{metadata.ReplaceId}' registration does not exist."; 51 | throw new Exception(message); 52 | } 53 | 54 | var registerStep = registrations[metadata.ReplaceId]; 55 | registerStep.Replace(metadata); 56 | } 57 | 58 | // Step 3: validate the removals 59 | foreach (var metadata in removals.Distinct(idComparer)) 60 | { 61 | if (!registrations.ContainsKey(metadata.RemoveId)) 62 | { 63 | var message = 64 | $"You cannot remove step registration with id '{metadata.RemoveId}', registration does not exist."; 65 | throw new Exception(message); 66 | } 67 | 68 | if (listOfBeforeAndAfterIds.Contains(metadata.RemoveId, StringComparer.CurrentCultureIgnoreCase)) 69 | { 70 | var add = 71 | additions.First( 72 | mr => 73 | (mr.Befores != null && 74 | mr.Befores.Select(b => b.DependsOnId) 75 | .Contains(metadata.RemoveId, StringComparer.CurrentCultureIgnoreCase)) || 76 | (mr.Afters != null && 77 | mr.Afters.Select(b => b.DependsOnId) 78 | .Contains(metadata.RemoveId, StringComparer.CurrentCultureIgnoreCase))); 79 | 80 | var message = 81 | $"You cannot remove step registration with id '{metadata.RemoveId}', registration with id '{add.StepId}' depends on it."; 82 | throw new Exception(message); 83 | } 84 | 85 | registrations.Remove(metadata.RemoveId); 86 | } 87 | 88 | var stages = registrations.Values.GroupBy(r => r.GetInputContext()) 89 | .ToList(); 90 | 91 | var finalOrder = new List(); 92 | 93 | if (registrations.Count == 0) 94 | { 95 | return finalOrder; 96 | } 97 | 98 | var currentStage = stages.SingleOrDefault(stage => stage.Key == rootContextType); 99 | 100 | if (currentStage == null) 101 | { 102 | throw new Exception( 103 | $"Can't find any behaviors/connectors for the root context ({rootContextType.FullName})"); 104 | } 105 | 106 | var stageNumber = 1; 107 | 108 | while (currentStage != null) 109 | { 110 | var stageSteps = currentStage.Where(stageStep => !IsStageConnector(stageStep)).ToList(); 111 | 112 | //add the stage connector 113 | finalOrder.AddRange(Sort(stageSteps)); 114 | 115 | var stageConnectors = currentStage.Where(IsStageConnector).ToList(); 116 | 117 | if (stageConnectors.Count > 1) 118 | { 119 | var connectors = $"'{string.Join("', '", stageConnectors.Select(sc => sc.BehaviorType.FullName))}'"; 120 | throw new Exception( 121 | $"Multiple stage connectors found for stage '{currentStage.Key.FullName}'. Remove one of: {connectors}"); 122 | } 123 | 124 | var stageConnector = stageConnectors.FirstOrDefault(); 125 | 126 | if (stageConnector == null) 127 | { 128 | if (stageNumber < stages.Count) 129 | { 130 | throw new Exception($"No stage connector found for stage {currentStage.Key.FullName}"); 131 | } 132 | 133 | currentStage = null; 134 | } 135 | else 136 | { 137 | finalOrder.Add(stageConnector); 138 | 139 | if (typeof(IPipelineTerminator).IsAssignableFrom(stageConnector.BehaviorType)) 140 | { 141 | currentStage = null; 142 | } 143 | else 144 | { 145 | var args = stageConnector.BehaviorType.BaseType.GetGenericArguments(); 146 | var stageEndType = args[1]; 147 | currentStage = stages.SingleOrDefault(stage => stage.Key == stageEndType); 148 | } 149 | } 150 | 151 | stageNumber++; 152 | } 153 | 154 | return finalOrder; 155 | } 156 | 157 | static bool IsStageConnector(RegisterStep stageStep) 158 | { 159 | return typeof(IStageConnector).IsAssignableFrom(stageStep.BehaviorType); 160 | } 161 | 162 | static IEnumerable Sort(List registrations) 163 | { 164 | if (registrations.Count == 0) 165 | { 166 | return registrations; 167 | } 168 | 169 | // Step 1: create nodes for graph 170 | var nameToNode = new Dictionary(); 171 | var allNodes = new List(); 172 | foreach (var rego in registrations) 173 | { 174 | // create entries to preserve order within 175 | var node = new Node(rego); 176 | nameToNode[rego.StepId] = node; 177 | allNodes.Add(node); 178 | } 179 | 180 | // Step 2: create edges from InsertBefore/InsertAfter values 181 | foreach (var node in allNodes) 182 | { 183 | ProcessBefores(node, nameToNode); 184 | ProcessAfters(node, nameToNode); 185 | } 186 | 187 | // Step 3: Perform Topological Sort 188 | var output = new List(); 189 | foreach (var node in allNodes) 190 | { 191 | node.Visit(output); 192 | } 193 | 194 | return output; 195 | } 196 | 197 | static void ProcessBefores(Node node, Dictionary nameToNode) 198 | { 199 | if (node.Befores == null) 200 | { 201 | return; 202 | } 203 | foreach (var beforeReference in node.Befores) 204 | { 205 | Node referencedNode; 206 | if (nameToNode.TryGetValue(beforeReference.DependsOnId, out referencedNode)) 207 | { 208 | referencedNode.previous.Add(node); 209 | continue; 210 | } 211 | var currentStepIds = GetCurrentIds(nameToNode); 212 | var message = 213 | $"Registration '{beforeReference.DependsOnId}' specified in the insertbefore of the '{node.StepId}' step does not exist. Current StepIds: {currentStepIds}"; 214 | 215 | if (!beforeReference.Enforce) 216 | { 217 | } 218 | else 219 | { 220 | throw new Exception(message); 221 | } 222 | } 223 | } 224 | 225 | static void ProcessAfters(Node node, Dictionary nameToNode) 226 | { 227 | if (node.Afters == null) 228 | { 229 | return; 230 | } 231 | foreach (var afterReference in node.Afters) 232 | { 233 | Node referencedNode; 234 | if (nameToNode.TryGetValue(afterReference.DependsOnId, out referencedNode)) 235 | { 236 | node.previous.Add(referencedNode); 237 | continue; 238 | } 239 | var currentStepIds = GetCurrentIds(nameToNode); 240 | var message = 241 | $"Registration '{afterReference.DependsOnId}' specified in the insertafter of the '{node.StepId}' step does not exist. Current StepIds: {currentStepIds}"; 242 | 243 | if (!afterReference.Enforce) 244 | { 245 | } 246 | else 247 | { 248 | throw new Exception(message); 249 | } 250 | } 251 | } 252 | 253 | static string GetCurrentIds(Dictionary nameToNodeDict) 254 | { 255 | return $"'{string.Join("', '", nameToNodeDict.Keys)}'"; 256 | } 257 | 258 | List additions; 259 | List removals; 260 | List replacements; 261 | 262 | Type rootContextType; 263 | static CaseInsensitiveIdComparer idComparer = new CaseInsensitiveIdComparer(); 264 | 265 | class Node 266 | { 267 | public Node(RegisterStep registerStep) 268 | { 269 | rego = registerStep; 270 | Befores = registerStep.Befores; 271 | Afters = registerStep.Afters; 272 | StepId = registerStep.StepId; 273 | 274 | OutputContext = registerStep.GetOutputContext(); 275 | } 276 | 277 | public Type OutputContext { get; private set; } 278 | 279 | internal void Visit(List output) 280 | { 281 | if (visited) 282 | { 283 | return; 284 | } 285 | visited = true; 286 | foreach (var n in previous) 287 | { 288 | n.Visit(output); 289 | } 290 | if (rego != null) 291 | { 292 | output.Add(rego); 293 | } 294 | } 295 | 296 | public List Afters; 297 | public List Befores; 298 | 299 | public string StepId; 300 | internal List previous = new List(); 301 | RegisterStep rego; 302 | bool visited; 303 | } 304 | 305 | class CaseInsensitiveIdComparer : IEqualityComparer 306 | { 307 | public bool Equals(RemoveStep x, RemoveStep y) 308 | { 309 | return x.RemoveId.Equals(y.RemoveId, StringComparison.CurrentCultureIgnoreCase); 310 | } 311 | 312 | public int GetHashCode(RemoveStep obj) 313 | { 314 | return obj.RemoveId.ToLower().GetHashCode(); 315 | } 316 | } 317 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/PipelineModifications.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | public class PipelineModifications 4 | { 5 | public List Additions = new List(); 6 | public List Removals = new List(); 7 | public List Replacements = new List(); 8 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/PipelineTerminator.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | public abstract class PipelineTerminator : StageConnector.ITerminatingContext>, 4 | IPipelineTerminator where T : IBehaviorContext 5 | { 6 | 7 | protected abstract Task Terminate(T context); 8 | 9 | public sealed override Task Invoke(T context, Func next) 10 | { 11 | return Terminate(context); 12 | } 13 | 14 | public interface ITerminatingContext : IBehaviorContext 15 | { 16 | } 17 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/ReadOnlySettings.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | public interface ReadOnlySettings 4 | { 5 | T Get(); 6 | 7 | T Get(string key); 8 | 9 | bool TryGet(out T val); 10 | 11 | bool TryGet(string key, out T val); 12 | 13 | object Get(string key); 14 | 15 | T GetOrDefault(); 16 | 17 | T GetOrDefault(string key); 18 | 19 | bool HasSetting(string key); 20 | 21 | bool HasSetting(); 22 | 23 | bool HasExplicitValue(string key); 24 | 25 | bool HasExplicitValue(); 26 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/RegisterStep.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace NServiceBus.Pipeline; 4 | 5 | [DebuggerDisplay("{StepId}({BehaviorType.FullName}) - {Description}")] 6 | public abstract class RegisterStep 7 | { 8 | /// 9 | /// Initializes a new instance of the class. 10 | /// 11 | /// The unique identifier for this steps. 12 | /// The type of to register. 13 | /// A brief description of what this step does. 14 | /// A factory method for creating the behavior. 15 | protected RegisterStep(string stepId, Type behavior, string description, 16 | Func factoryMethod = null) 17 | { 18 | this.factoryMethod = factoryMethod; 19 | 20 | BehaviorType = behavior; 21 | StepId = stepId; 22 | Description = description; 23 | } 24 | 25 | /// 26 | /// Gets the unique identifier for this step. 27 | /// 28 | public string StepId { get; } 29 | 30 | /// 31 | /// Gets the description for this registration. 32 | /// 33 | public string Description { get; private set; } 34 | 35 | internal List Befores { get; private set; } 36 | internal List Afters { get; private set; } 37 | 38 | /// 39 | /// Gets the type of that is being registered. 40 | /// 41 | public Type BehaviorType { get; private set; } 42 | 43 | /// 44 | /// Checks if this behavior is enabled. 45 | /// 46 | public virtual bool IsEnabled(ReadOnlySettings settings) 47 | { 48 | return true; 49 | } 50 | 51 | /// 52 | /// Instructs the pipeline to register this step before the one. If the does 53 | /// not exist, this condition is ignored. 54 | /// 55 | /// The unique identifier of the step that we want to insert before. 56 | public void InsertBeforeIfExists(string id) 57 | { 58 | 59 | if (Befores == null) 60 | { 61 | Befores = new List(); 62 | } 63 | 64 | Befores.Add(new Dependency(StepId, id, Dependency.DependencyDirection.Before, false)); 65 | } 66 | 67 | /// 68 | /// Instructs the pipeline to register this step before the one. 69 | /// 70 | public void InsertBefore(string id) 71 | { 72 | if (Befores == null) 73 | { 74 | Befores = new List(); 75 | } 76 | 77 | Befores.Add(new Dependency(StepId, id, Dependency.DependencyDirection.Before, true)); 78 | } 79 | 80 | /// 81 | /// Instructs the pipeline to register this step after the one. If the does 82 | /// not exist, this condition is ignored. 83 | /// 84 | /// The unique identifier of the step that we want to insert after. 85 | public void InsertAfterIfExists(string id) 86 | { 87 | if (Afters == null) 88 | { 89 | Afters = new List(); 90 | } 91 | 92 | Afters.Add(new Dependency(StepId, id, Dependency.DependencyDirection.After, false)); 93 | } 94 | 95 | /// 96 | /// Instructs the pipeline to register this step after the one. 97 | /// 98 | public void InsertAfter(string id) 99 | { 100 | if (Afters == null) 101 | { 102 | Afters = new List(); 103 | } 104 | 105 | Afters.Add(new Dependency(StepId, id, Dependency.DependencyDirection.After, true)); 106 | } 107 | 108 | internal void Replace(ReplaceStep replacement) 109 | { 110 | if (StepId != replacement.ReplaceId) 111 | { 112 | throw new InvalidOperationException( 113 | $"Cannot replace step '{StepId}' with '{replacement.ReplaceId}'. The ID of the replacement must match the replaced step."); 114 | } 115 | 116 | BehaviorType = replacement.BehaviorType; 117 | factoryMethod = replacement.FactoryMethod; 118 | 119 | if (!string.IsNullOrWhiteSpace(replacement.Description)) 120 | { 121 | Description = replacement.Description; 122 | } 123 | } 124 | 125 | internal IBehavior CreateBehaviorNew(IBuilder defaultBuilder) 126 | { 127 | var behavior = factoryMethod != null 128 | ? factoryMethod(defaultBuilder) 129 | : (IBehavior) defaultBuilder.Build(BehaviorType); 130 | 131 | return behavior; 132 | } 133 | 134 | internal BehaviorInstance CreateBehaviorOld(IBuilder defaultBuilder) 135 | { 136 | var behavior = factoryMethod != null 137 | ? factoryMethod(defaultBuilder) 138 | : (IBehavior) defaultBuilder.Build(BehaviorType); 139 | 140 | return new BehaviorInstance(BehaviorType, behavior); 141 | } 142 | 143 | internal static RegisterStep Create(string pipelineStep, Type behavior, string description, 144 | Func factoryMethod = null) 145 | { 146 | return new DefaultRegisterStep(behavior, pipelineStep, description, factoryMethod); 147 | } 148 | 149 | Func factoryMethod; 150 | 151 | class DefaultRegisterStep : RegisterStep 152 | { 153 | public DefaultRegisterStep(Type behavior, string stepId, string description, 154 | Func factoryMethod) 155 | : base(stepId, behavior, description, factoryMethod) 156 | { 157 | } 158 | } 159 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/RegisterStepExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | static class RegisterStepExtensions 4 | { 5 | public static bool IsStageConnector(this RegisterStep step) 6 | { 7 | return typeof(IStageConnector).IsAssignableFrom(step.BehaviorType); 8 | } 9 | 10 | public static Type GetContextType(this Type behaviorType) 11 | { 12 | var behaviorInterface = behaviorType.GetBehaviorInterface(); 13 | return behaviorInterface.GetGenericArguments()[0]; 14 | } 15 | 16 | public static bool IsBehavior(this Type behaviorType) 17 | { 18 | return behaviorType.GetInterfaces() 19 | .Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == BehaviorInterfaceType); 20 | } 21 | 22 | public static Type GetBehaviorInterface(this Type behaviorType) 23 | { 24 | return behaviorType.GetInterfaces() 25 | .First(x => x.IsGenericType && x.GetGenericTypeDefinition() == BehaviorInterfaceType); 26 | } 27 | 28 | public static Type GetOutputContext(this RegisterStep step) 29 | { 30 | return step.BehaviorType.GetOutputContext(); 31 | } 32 | 33 | public static Type GetOutputContext(this Type behaviorType) 34 | { 35 | var behaviorInterface = GetBehaviorInterface(behaviorType); 36 | return behaviorInterface.GetGenericArguments()[1]; 37 | } 38 | 39 | public static Type GetInputContext(this RegisterStep step) 40 | { 41 | return step.BehaviorType.GetInputContext(); 42 | } 43 | 44 | public static Type GetInputContext(this Type behaviorType) 45 | { 46 | var behaviorInterface = GetBehaviorInterface(behaviorType); 47 | return behaviorInterface.GetGenericArguments()[0]; 48 | } 49 | 50 | static Type BehaviorInterfaceType = typeof(IBehavior<,>); 51 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/RemoveStep.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | public class RemoveStep 4 | { 5 | public RemoveStep(string removeId) 6 | { 7 | RemoveId = removeId; 8 | } 9 | 10 | public string RemoveId { get; private set; } 11 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/ReplaceStep.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Toolchains; 2 | 3 | namespace NServiceBus.Pipeline; 4 | 5 | public class ReplaceStep 6 | { 7 | public ReplaceStep(string idToReplace, Type behavior, string description = null, 8 | Func factoryMethod = null) 9 | { 10 | ReplaceId = idToReplace; 11 | Description = description; 12 | BehaviorType = behavior; 13 | FactoryMethod = factoryMethod; 14 | } 15 | 16 | public string ReplaceId { get; } 17 | public string Description { get; } 18 | public Type BehaviorType { get; } 19 | public Func FactoryMethod { get; } 20 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/SettingsHolder.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Concurrent; 2 | 3 | namespace NServiceBus.Pipeline; 4 | 5 | public class SettingsHolder : ReadOnlySettings 6 | { 7 | public T Get(string key) 8 | { 9 | return (T) Get(key); 10 | } 11 | 12 | public bool TryGet(out T val) 13 | { 14 | return TryGet(typeof(T).FullName, out val); 15 | } 16 | 17 | public bool TryGet(string key, out T val) 18 | { 19 | val = default(T); 20 | 21 | object tmp; 22 | if (!Overrides.TryGetValue(key, out tmp)) 23 | { 24 | if (!Defaults.TryGetValue(key, out tmp)) 25 | { 26 | return false; 27 | } 28 | } 29 | 30 | if (!(tmp is T)) 31 | { 32 | return false; 33 | } 34 | 35 | val = (T) tmp; 36 | return true; 37 | } 38 | 39 | public T Get() 40 | { 41 | return (T) Get(typeof(T).FullName); 42 | } 43 | 44 | public object Get(string key) 45 | { 46 | object result; 47 | if (Overrides.TryGetValue(key, out result)) 48 | { 49 | return result; 50 | } 51 | 52 | if (Defaults.TryGetValue(key, out result)) 53 | { 54 | return result; 55 | } 56 | 57 | throw new KeyNotFoundException($"The given key ({key}) was not present in the dictionary."); 58 | } 59 | 60 | public T GetOrDefault() 61 | { 62 | return GetOrDefault(typeof(T).FullName); 63 | } 64 | 65 | public T GetOrDefault(string key) 66 | { 67 | object result; 68 | if (Overrides.TryGetValue(key, out result)) 69 | { 70 | return (T) result; 71 | } 72 | 73 | if (Defaults.TryGetValue(key, out result)) 74 | { 75 | return (T) result; 76 | } 77 | 78 | return default(T); 79 | } 80 | 81 | public bool HasSetting(string key) 82 | { 83 | return Overrides.ContainsKey(key) || Defaults.ContainsKey(key); 84 | } 85 | 86 | public bool HasSetting() 87 | { 88 | var key = typeof(T).FullName; 89 | 90 | return HasSetting(key); 91 | } 92 | 93 | public bool HasExplicitValue(string key) 94 | { 95 | return Overrides.ContainsKey(key); 96 | } 97 | 98 | public bool HasExplicitValue() 99 | { 100 | var key = typeof(T).FullName; 101 | 102 | return HasExplicitValue(key); 103 | } 104 | 105 | public T GetOrCreate() 106 | where T : class, new() 107 | { 108 | T value; 109 | if (!TryGet(out value)) 110 | { 111 | value = new T(); 112 | Set(value); 113 | } 114 | return value; 115 | } 116 | 117 | public void Set(string key, object value) 118 | { 119 | EnsureWriteEnabled(key); 120 | 121 | Overrides[key] = value; 122 | } 123 | 124 | public void Set(object value) 125 | { 126 | Set(typeof(T).FullName, value); 127 | } 128 | 129 | public void Set(Action value) 130 | { 131 | Set(typeof(T).FullName, value); 132 | } 133 | 134 | public void SetDefault(object value) 135 | { 136 | SetDefault(typeof(T).FullName, value); 137 | } 138 | 139 | public void SetDefault(Action value) 140 | { 141 | SetDefault(typeof(T).FullName, value); 142 | } 143 | 144 | public void SetDefault(string key, object value) 145 | { 146 | EnsureWriteEnabled(key); 147 | 148 | Defaults[key] = value; 149 | } 150 | 151 | internal void PreventChanges() 152 | { 153 | locked = true; 154 | } 155 | 156 | internal void Merge(ReadOnlySettings settings) 157 | { 158 | EnsureMergingIsPossible(); 159 | 160 | var holder = settings as SettingsHolder ?? new SettingsHolder(); 161 | 162 | foreach (var @default in holder.Defaults) 163 | { 164 | Defaults[@default.Key] = @default.Value; 165 | } 166 | 167 | foreach (var @override in holder.Overrides) 168 | { 169 | Overrides[@override.Key] = @override.Value; 170 | } 171 | } 172 | 173 | void EnsureMergingIsPossible() 174 | { 175 | if (locked) 176 | { 177 | throw new Exception( 178 | "Unable to merge settings. The settings has been locked for modifications. Move any configuration code earlier in the configuration pipeline"); 179 | } 180 | } 181 | 182 | void EnsureWriteEnabled(string key) 183 | { 184 | if (locked) 185 | { 186 | throw new Exception( 187 | $"Unable to set the value for key: {key}. The settings has been locked for modifications. Move any configuration code earlier in the configuration pipeline"); 188 | } 189 | } 190 | 191 | public void Clear() 192 | { 193 | foreach (var item in Defaults) 194 | { 195 | (item.Value as IDisposable)?.Dispose(); 196 | } 197 | 198 | Defaults.Clear(); 199 | 200 | foreach (var item in Overrides) 201 | { 202 | (item.Value as IDisposable)?.Dispose(); 203 | } 204 | 205 | Overrides.Clear(); 206 | } 207 | 208 | ConcurrentDictionary Defaults = 209 | new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); 210 | 211 | bool locked; 212 | 213 | ConcurrentDictionary Overrides = 214 | new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); 215 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/StageConnector.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | public abstract class StageConnector : IBehavior, 4 | IStageConnector 5 | where TFromContext : IBehaviorContext 6 | where TToContext : IBehaviorContext 7 | { 8 | public abstract Task Invoke(TFromContext context, Func stage); 9 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Pipeline/StepRegistrationsCoordinator.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | class StepRegistrationsCoordinator 4 | { 5 | public StepRegistrationsCoordinator(List removals, List replacements) 6 | { 7 | this.removals = removals; 8 | this.replacements = replacements; 9 | } 10 | 11 | public void Register(string pipelineStep, Type behavior, string description) 12 | { 13 | additions.Add(RegisterStep.Create(pipelineStep, behavior, description)); 14 | } 15 | 16 | public void Register(RegisterStep rego) 17 | { 18 | additions.Add(rego); 19 | } 20 | 21 | public List BuildPipelineModelFor() where TRootContext : IBehaviorContext 22 | { 23 | var relevantRemovals = removals.Where(removal => additions.Any(a => a.StepId == removal.RemoveId)).ToList(); 24 | var relevantReplacements = 25 | replacements.Where(removal => additions.Any(a => a.StepId == removal.ReplaceId)).ToList(); 26 | 27 | var piplineModelBuilder = new PipelineModelBuilder(typeof(TRootContext), additions, relevantRemovals, 28 | relevantReplacements); 29 | 30 | return piplineModelBuilder.Build(); 31 | } 32 | 33 | List additions = new List(); 34 | List removals; 35 | List replacements; 36 | } -------------------------------------------------------------------------------- /PipelineOptimizations/PipelineOptimizations.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net7.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /PipelineOptimizations/PipelineOptimizations.csproj.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True -------------------------------------------------------------------------------- /PipelineOptimizations/PipelineTests.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelineOptimizations/PipelineTests.png -------------------------------------------------------------------------------- /PipelineOptimizations/Program.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Running; 2 | 3 | var switcher = new BenchmarkSwitcher(typeof(Program).Assembly); 4 | switcher.Run(args); -------------------------------------------------------------------------------- /PipelineOptimizations/Step1/BehaviorExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Linq.Expressions; 2 | using System.Reflection; 3 | using FastExpressionCompiler; 4 | using NServiceBus.Pipeline; 5 | 6 | namespace PipelineOptimizations.Step1; 7 | 8 | static class BehaviorExtensions 9 | { 10 | // ReSharper disable once SuggestBaseTypeForParameter 11 | public static Func CreatePipelineExecutionFuncFor(this IBehavior[] behaviors, List expressions = null) 12 | where TRootContext : IBehaviorContext 13 | { 14 | return (Func)behaviors.CreatePipelineExecutionExpression(); 15 | } 16 | 17 | /// 18 | /// rootContext 19 | /// => behavior1.Invoke(rootContext, 20 | /// context1 => behavior2.Invoke(context1, 21 | /// ... 22 | /// context{N} => behavior{N}.Invoke(context{N}, 23 | /// context{N+1} => TaskEx.Completed)) 24 | /// 25 | public static Delegate CreatePipelineExecutionExpression(this IBehavior[] behaviors, List expressions = null) 26 | { 27 | Delegate lambdaExpression = null; 28 | var length = behaviors.Length - 1; 29 | // We start from the end of the list know the lambda expressions deeper in the call stack in advance 30 | for (var i = length; i >= 0; i--) 31 | { 32 | var currentBehavior = behaviors[i]; 33 | var behaviorInterfaceType = currentBehavior.GetType().GetInterfaces().FirstOrDefault(t => t.GetGenericArguments().Length == 2 && t.FullName.StartsWith("NServiceBus.Pipeline.IBehavior")); 34 | if (behaviorInterfaceType == null) 35 | { 36 | throw new InvalidOperationException("Behaviors must implement IBehavior"); 37 | } 38 | var methodInfo = behaviorInterfaceType.GetMethods().FirstOrDefault(); 39 | if (methodInfo == null) 40 | { 41 | throw new InvalidOperationException("Behaviors must implement IBehavior and provide an invocation method."); 42 | } 43 | 44 | var genericArguments = behaviorInterfaceType.GetGenericArguments(); 45 | var inContextType = genericArguments[0]; 46 | 47 | var inContextParameter = Expression.Parameter(inContextType, $"context{i}"); 48 | 49 | if (i == length) 50 | { 51 | if (currentBehavior is IPipelineTerminator) 52 | { 53 | inContextType = typeof(PipelineTerminator<>.ITerminatingContext).MakeGenericType(inContextType); 54 | } 55 | var doneDelegate = CreateDoneDelegate(inContextType, i); 56 | lambdaExpression = CreateBehaviorCallDelegate(currentBehavior, methodInfo, inContextParameter, doneDelegate, expressions); 57 | continue; 58 | } 59 | 60 | lambdaExpression = CreateBehaviorCallDelegate(currentBehavior, methodInfo, inContextParameter, lambdaExpression, expressions); 61 | } 62 | 63 | return lambdaExpression; 64 | } 65 | 66 | // ReSharper disable once SuggestBaseTypeForParameter 67 | 68 | /// 69 | /// context{i} => behavior.Invoke(context{i}, context{i+1} => previous) 70 | /// > 71 | static Delegate CreateBehaviorCallDelegate(IBehavior currentBehavior, MethodInfo methodInfo, ParameterExpression outerContextParam, Delegate previous, List expressions = null) 72 | { 73 | Expression body = Expression.Call(Expression.Constant(currentBehavior), methodInfo, outerContextParam, Expression.Constant(previous)); 74 | var lambdaExpression = Expression.Lambda(body, outerContextParam); 75 | expressions?.Add(lambdaExpression); 76 | return lambdaExpression.CompileFast(); 77 | } 78 | 79 | /// 80 | /// context{i} => return TaskEx.CompletedTask; 81 | /// > 82 | static Delegate CreateDoneDelegate(Type inContextType, int i) 83 | { 84 | var innerContextParam = Expression.Parameter(inContextType, $"context{i + 1}"); 85 | return Expression.Lambda(typeof(Func<,>).MakeGenericType(inContextType, typeof(Task)), Expression.Constant(Task.CompletedTask), innerContextParam).CompileFast(); 86 | } 87 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Step1/BehaviorOptimization.cs: -------------------------------------------------------------------------------- 1 | using NServiceBus.Pipeline; 2 | 3 | namespace PipelineOptimizations.Step1; 4 | 5 | public class BehaviorOptimization : IBehavior 6 | { 7 | public Task Invoke(IBehaviorContext context, Func next) 8 | { 9 | return next(context); 10 | } 11 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Step1/PipelineOptimization.cs: -------------------------------------------------------------------------------- 1 | using NServiceBus.Pipeline; 2 | 3 | namespace PipelineOptimizations.Step1; 4 | 5 | public class PipelineOptimization 6 | where TContext : IBehaviorContext 7 | { 8 | public PipelineOptimization(IBuilder builder, ReadOnlySettings settings, 9 | PipelineModifications pipelineModifications) 10 | { 11 | var coordinator = new StepRegistrationsCoordinator(pipelineModifications.Removals, 12 | pipelineModifications.Replacements); 13 | 14 | foreach (var rego in pipelineModifications.Additions.Where(x => x.IsEnabled(settings))) 15 | { 16 | coordinator.Register(rego); 17 | } 18 | 19 | // Important to keep a reference 20 | behaviors = coordinator.BuildPipelineModelFor() 21 | .Select(r => r.CreateBehaviorNew(builder)).ToArray(); 22 | 23 | pipeline = behaviors.CreatePipelineExecutionFuncFor(); 24 | } 25 | 26 | public Task Invoke(TContext context) 27 | { 28 | return pipeline(context); 29 | } 30 | 31 | // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable 32 | IBehavior[] behaviors; 33 | Func pipeline; 34 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Step1/Step1_PipelineException.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Attributes; 2 | using BenchmarkDotNet.Configs; 3 | using BenchmarkDotNet.Diagnosers; 4 | using BenchmarkDotNet.Jobs; 5 | using NServiceBus.Pipeline; 6 | 7 | namespace PipelineOptimizations.Step1; 8 | 9 | [ShortRunJob] 10 | [MemoryDiagnoser] 11 | public class Step1_PipelineException 12 | { 13 | [Params(10, 20, 40)] 14 | public int PipelineDepth { get; set; } 15 | 16 | private BehaviorContext behaviorContext; 17 | private PipelineModifications pipelineModificationsBeforeOptimizations; 18 | private PipelineModifications pipelineModificationsAfterOptimizations; 19 | private BaseLinePipeline pipelineBeforeOptimizations; 20 | private PipelineOptimization pipelineAfterOptimizations; 21 | 22 | [GlobalSetup] 23 | public void SetUp() 24 | { 25 | behaviorContext = new BehaviorContext(); 26 | 27 | pipelineModificationsBeforeOptimizations = new PipelineModifications(); 28 | for (int i = 0; i < PipelineDepth; i++) 29 | { 30 | pipelineModificationsBeforeOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 31 | typeof(BaseLineBehavior), i.ToString(), b => new BaseLineBehavior())); 32 | } 33 | var stepdId = PipelineDepth + 1; 34 | pipelineModificationsBeforeOptimizations.Additions.Add(RegisterStep.Create(stepdId.ToString(), typeof(Throwing), "1", b => new Throwing())); 35 | 36 | pipelineModificationsAfterOptimizations = new PipelineModifications(); 37 | for (int i = 0; i < PipelineDepth; i++) 38 | { 39 | pipelineModificationsAfterOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 40 | typeof(BehaviorOptimization), i.ToString(), b => new BehaviorOptimization())); 41 | } 42 | pipelineModificationsAfterOptimizations.Additions.Add(RegisterStep.Create(stepdId.ToString(), typeof(Throwing), "1", b => new Throwing())); 43 | 44 | pipelineBeforeOptimizations = new BaseLinePipeline(null, new SettingsHolder(), 45 | pipelineModificationsBeforeOptimizations); 46 | pipelineAfterOptimizations = new PipelineOptimization(null, new SettingsHolder(), 47 | pipelineModificationsAfterOptimizations); 48 | } 49 | 50 | [Benchmark(Baseline = true)] 51 | public async Task Before() 52 | { 53 | try 54 | { 55 | await pipelineBeforeOptimizations.Invoke(behaviorContext).ConfigureAwait(false); 56 | } 57 | catch (InvalidOperationException) 58 | { 59 | } 60 | } 61 | 62 | [Benchmark] 63 | public async Task After() 64 | { 65 | try 66 | { 67 | await pipelineAfterOptimizations.Invoke(behaviorContext).ConfigureAwait(false); 68 | } 69 | catch (InvalidOperationException) 70 | { 71 | } 72 | } 73 | 74 | class Throwing : Behavior 75 | { 76 | public override Task Invoke(IBehaviorContext context, Func next) 77 | { 78 | throw new InvalidOperationException(); 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Step1/Step1_PipelineExecution.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Attributes; 2 | using NServiceBus.Pipeline; 3 | 4 | namespace PipelineOptimizations.Step1; 5 | 6 | [ShortRunJob] 7 | [MemoryDiagnoser] 8 | public class Step1_PipelineExecution 9 | { 10 | [Params(10, 20, 40)] 11 | public int PipelineDepth { get; set; } 12 | 13 | 14 | [GlobalSetup] 15 | public void SetUp() 16 | { 17 | behaviorContext = new BehaviorContext(); 18 | 19 | pipelineModificationsBeforeOptimizations = new PipelineModifications(); 20 | for (int i = 0; i < PipelineDepth; i++) 21 | { 22 | pipelineModificationsBeforeOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 23 | typeof(BaseLineBehavior), i.ToString(), b => new BaseLineBehavior())); 24 | } 25 | 26 | pipelineModificationsAfterOptimizations = new PipelineModifications(); 27 | for (int i = 0; i < PipelineDepth; i++) 28 | { 29 | pipelineModificationsAfterOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 30 | typeof(BehaviorOptimization), i.ToString(), b => new BehaviorOptimization())); 31 | } 32 | 33 | pipelineBeforeOptimizations = new BaseLinePipeline(null, new SettingsHolder(), 34 | pipelineModificationsBeforeOptimizations); 35 | pipelineAfterOptimizations = new PipelineOptimization(null, new SettingsHolder(), 36 | pipelineModificationsAfterOptimizations); 37 | } 38 | 39 | [Benchmark(Baseline = true)] 40 | public async Task Before() 41 | { 42 | await pipelineBeforeOptimizations.Invoke(behaviorContext); 43 | } 44 | 45 | [Benchmark] 46 | public async Task After() 47 | { 48 | await pipelineAfterOptimizations.Invoke(behaviorContext); 49 | } 50 | 51 | private BehaviorContext behaviorContext; 52 | private PipelineModifications pipelineModificationsBeforeOptimizations; 53 | private PipelineModifications pipelineModificationsAfterOptimizations; 54 | private BaseLinePipeline pipelineBeforeOptimizations; 55 | private PipelineOptimization pipelineAfterOptimizations; 56 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Step1/Step1_PipelineWarmup.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Attributes; 2 | using BenchmarkDotNet.Configs; 3 | using BenchmarkDotNet.Diagnosers; 4 | using BenchmarkDotNet.Jobs; 5 | using NServiceBus.Pipeline; 6 | 7 | namespace PipelineOptimizations.Step1; 8 | 9 | [ShortRunJob] 10 | [MemoryDiagnoser] 11 | public class Step1_PipelineWarmup 12 | { 13 | [Params(10, 20, 40)] 14 | public int PipelineDepth { get; set; } 15 | 16 | private PipelineModifications pipelineModificationsBeforeOptimizations; 17 | private PipelineModifications pipelineModificationsAfterOptimizations; 18 | 19 | [GlobalSetup] 20 | public void SetUp() 21 | { 22 | pipelineModificationsBeforeOptimizations = new PipelineModifications(); 23 | for (int i = 0; i < PipelineDepth; i++) 24 | { 25 | pipelineModificationsBeforeOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 26 | typeof(BaseLineBehavior), i.ToString(), b => new BaseLineBehavior())); 27 | } 28 | 29 | pipelineModificationsAfterOptimizations = new PipelineModifications(); 30 | for (int i = 0; i < PipelineDepth; i++) 31 | { 32 | pipelineModificationsAfterOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 33 | typeof(BehaviorOptimization), i.ToString(), b => new BehaviorOptimization())); 34 | } 35 | } 36 | 37 | [Benchmark(Baseline = true)] 38 | public BaseLinePipeline Before() 39 | { 40 | var pipelineBeforeOptimizations = new BaseLinePipeline(null, new SettingsHolder(), 41 | pipelineModificationsBeforeOptimizations); 42 | return pipelineBeforeOptimizations; 43 | } 44 | 45 | [Benchmark] 46 | public PipelineOptimization After() 47 | { 48 | var pipelineAfterOptimizations = new PipelineOptimization(null, new SettingsHolder(), 49 | pipelineModificationsAfterOptimizations); 50 | return pipelineAfterOptimizations; 51 | } 52 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Step2/BehaviorExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Linq.Expressions; 2 | using System.Reflection; 3 | using FastExpressionCompiler; 4 | using NServiceBus.Pipeline; 5 | 6 | namespace PipelineOptimizations.Step2; 7 | 8 | static class BehaviorExtensions 9 | { 10 | public static Func CreatePipelineExecutionFuncWithSmugglingFor(this IBehavior[] behaviors) 11 | where TRootContext : IBehaviorContext 12 | { 13 | return (Func)behaviors.CreatePipelineExecutionExpression(); 14 | } 15 | 16 | /// 17 | /// rootContext 18 | /// => behavior1.Invoke(rootContext, 19 | /// context1 => behavior2.Invoke(context1, 20 | /// ... 21 | /// context{N} => behavior{N}.Invoke(context{N}, 22 | /// context{N+1} => TaskEx.Completed)) 23 | /// 24 | public static Delegate CreatePipelineExecutionExpression(this IBehavior[] behaviors, List expressions = null) 25 | { 26 | Delegate lambdaExpression = null; 27 | var length = behaviors.Length - 1; 28 | // We start from the end of the list know the lambda expressions deeper in the call stack in advance 29 | for (var i = length; i >= 0; i--) 30 | { 31 | var currentBehavior = behaviors[i]; 32 | var behaviorInterfaceType = currentBehavior.GetType().GetInterfaces().FirstOrDefault(t => t.GetGenericArguments().Length == 2 && t.FullName.StartsWith("NServiceBus.Pipeline.IBehavior")); 33 | if (behaviorInterfaceType == null) 34 | { 35 | throw new InvalidOperationException("Behaviors must implement IBehavior"); 36 | } 37 | var methodInfo = behaviorInterfaceType.GetMethods().FirstOrDefault(); 38 | if (methodInfo == null) 39 | { 40 | throw new InvalidOperationException("Behaviors must implement IBehavior and provide an invocation method."); 41 | } 42 | 43 | var genericArguments = behaviorInterfaceType.GetGenericArguments(); 44 | var inContextType = genericArguments[0]; 45 | 46 | var inContextParameter = Expression.Parameter(inContextType, $"context{i}"); 47 | 48 | if (i == length) 49 | { 50 | if (currentBehavior is IPipelineTerminator) 51 | { 52 | inContextType = typeof(PipelineTerminator<>.ITerminatingContext).MakeGenericType(inContextType); 53 | } 54 | var doneDelegate = CreateDoneDelegate(inContextType, i); 55 | lambdaExpression = CreateBehaviorCallDelegate(methodInfo, inContextParameter, currentBehavior.GetType(), doneDelegate, i, expressions); 56 | continue; 57 | } 58 | 59 | lambdaExpression = CreateBehaviorCallDelegate(methodInfo, inContextParameter, currentBehavior.GetType(), lambdaExpression, i, expressions); 60 | } 61 | 62 | return lambdaExpression; 63 | } 64 | 65 | /// 66 | /// context{i} => behavior.Invoke(context{i}, context{i+1} => previous) 67 | /// > 68 | static Delegate CreateBehaviorCallDelegate(MethodInfo methodInfo, ParameterExpression outerContextParam, Type behaviorType, Delegate previous, int i, List expressions = null) 69 | { 70 | PropertyInfo extensionProperty = typeof(IExtendable).GetProperty("Extensions"); 71 | Expression extensionPropertyExpression = Expression.Property(outerContextParam, extensionProperty); 72 | PropertyInfo behaviorsProperty = typeof(ContextBag).GetProperty("Behaviors", BindingFlags.Instance | BindingFlags.NonPublic); 73 | Expression behaviorsPropertyExpression = Expression.Property(extensionPropertyExpression, behaviorsProperty); 74 | Expression indexerPropertyExpression = Expression.ArrayIndex(behaviorsPropertyExpression, Expression.Constant(i)); 75 | Expression castToBehavior = Expression.Convert(indexerPropertyExpression, behaviorType); 76 | Expression body = Expression.Call(castToBehavior, methodInfo, outerContextParam, Expression.Constant(previous)); 77 | var lambdaExpression = Expression.Lambda(body, outerContextParam); 78 | expressions?.Add(lambdaExpression); 79 | return lambdaExpression.CompileFast(); 80 | } 81 | 82 | /// 83 | /// context{i} => return TaskEx.CompletedTask; 84 | /// > 85 | static Delegate CreateDoneDelegate(Type inContextType, int i) 86 | { 87 | var innerContextParam = Expression.Parameter(inContextType, $"context{i + 1}"); 88 | return Expression.Lambda(Expression.Constant(Task.CompletedTask), innerContextParam).CompileFast(); 89 | } 90 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Step2/ContextBag.cs: -------------------------------------------------------------------------------- 1 | namespace NServiceBus.Pipeline; 2 | 3 | public partial class ContextBag 4 | { 5 | internal IBehavior[] Behaviors 6 | { 7 | get => behaviors ?? parentBag?.Behaviors; 8 | set => behaviors = value; 9 | } 10 | 11 | IBehavior[] behaviors; 12 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Step2/PipelineOptimization.cs: -------------------------------------------------------------------------------- 1 | using NServiceBus.Pipeline; 2 | 3 | namespace PipelineOptimizations.Step2; 4 | 5 | public class PipelineOptimization 6 | where TContext : IBehaviorContext 7 | { 8 | public PipelineOptimization(IBuilder builder, ReadOnlySettings settings, 9 | PipelineModifications pipelineModifications) 10 | { 11 | var coordinator = new StepRegistrationsCoordinator(pipelineModifications.Removals, 12 | pipelineModifications.Replacements); 13 | 14 | foreach (var rego in pipelineModifications.Additions.Where(x => x.IsEnabled(settings))) 15 | { 16 | coordinator.Register(rego); 17 | } 18 | 19 | // Important to keep a reference 20 | behaviors = coordinator.BuildPipelineModelFor() 21 | .Select(r => r.CreateBehaviorNew(builder)).ToArray(); 22 | 23 | pipeline = behaviors.CreatePipelineExecutionFuncWithSmugglingFor(); 24 | } 25 | 26 | public Task Invoke(TContext context) 27 | { 28 | context.Extensions.Behaviors = behaviors; 29 | return pipeline(context); 30 | } 31 | 32 | // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable 33 | IBehavior[] behaviors; 34 | Func pipeline; 35 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Step2/Step2_PipelineException.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Attributes; 2 | using BenchmarkDotNet.Configs; 3 | using BenchmarkDotNet.Diagnosers; 4 | using BenchmarkDotNet.Jobs; 5 | using NServiceBus.Pipeline; 6 | 7 | namespace PipelineOptimizations.Step2; 8 | 9 | [ShortRunJob] 10 | [MemoryDiagnoser] 11 | public class Step2_PipelineException 12 | { 13 | [Params(10, 20, 40)] 14 | public int PipelineDepth { get; set; } 15 | 16 | private BehaviorContext behaviorContext; 17 | private PipelineModifications pipelineModificationsBeforeOptimizations; 18 | private PipelineModifications pipelineModificationsAfterOptimizations; 19 | private Step1.PipelineOptimization pipelineBeforeOptimizations; 20 | private PipelineOptimization pipelineAfterOptimizations; 21 | 22 | [GlobalSetup] 23 | public void SetUp() 24 | { 25 | behaviorContext = new BehaviorContext(); 26 | 27 | pipelineModificationsBeforeOptimizations = new PipelineModifications(); 28 | for (int i = 0; i < PipelineDepth; i++) 29 | { 30 | pipelineModificationsBeforeOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 31 | typeof(Step1.BehaviorOptimization), i.ToString(), b => new Step1.BehaviorOptimization())); 32 | } 33 | var stepdId = PipelineDepth + 1; 34 | pipelineModificationsBeforeOptimizations.Additions.Add(RegisterStep.Create(stepdId.ToString(), typeof(Throwing), "1", b => new Throwing())); 35 | 36 | pipelineModificationsAfterOptimizations = new PipelineModifications(); 37 | for (int i = 0; i < PipelineDepth; i++) 38 | { 39 | pipelineModificationsAfterOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 40 | typeof(Step1.BehaviorOptimization), i.ToString(), b => new Step1.BehaviorOptimization())); 41 | } 42 | pipelineModificationsAfterOptimizations.Additions.Add(RegisterStep.Create(stepdId.ToString(), typeof(Throwing), "1", b => new Throwing())); 43 | 44 | pipelineBeforeOptimizations = new Step1.PipelineOptimization(null, new SettingsHolder(), 45 | pipelineModificationsBeforeOptimizations); 46 | pipelineAfterOptimizations = new PipelineOptimization(null, new SettingsHolder(), 47 | pipelineModificationsAfterOptimizations); 48 | } 49 | 50 | [Benchmark(Baseline = true)] 51 | public async Task Before() 52 | { 53 | try 54 | { 55 | await pipelineBeforeOptimizations.Invoke(behaviorContext).ConfigureAwait(false); 56 | } 57 | catch (InvalidOperationException) 58 | { 59 | } 60 | } 61 | 62 | [Benchmark] 63 | public async Task After() 64 | { 65 | try 66 | { 67 | await pipelineAfterOptimizations.Invoke(behaviorContext).ConfigureAwait(false); 68 | } 69 | catch (InvalidOperationException) 70 | { 71 | } 72 | } 73 | 74 | class Throwing : Behavior 75 | { 76 | public override Task Invoke(IBehaviorContext context, Func next) 77 | { 78 | throw new InvalidOperationException(); 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Step2/Step2_PipelineExecution.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Attributes; 2 | using BenchmarkDotNet.Configs; 3 | using BenchmarkDotNet.Diagnosers; 4 | using BenchmarkDotNet.Jobs; 5 | using NServiceBus.Pipeline; 6 | 7 | namespace PipelineOptimizations.Step2; 8 | 9 | [ShortRunJob] 10 | [MemoryDiagnoser] 11 | public class Step2_PipelineExecution 12 | { 13 | [Params(10, 20, 40)] 14 | public int PipelineDepth { get; set; } 15 | 16 | private BehaviorContext behaviorContext; 17 | private PipelineModifications pipelineModificationsBeforeOptimizations; 18 | private PipelineModifications pipelineModificationsAfterOptimizations; 19 | private Step1.PipelineOptimization pipelineBeforeOptimizations; 20 | private PipelineOptimization pipelineAfterOptimizations; 21 | 22 | [GlobalSetup] 23 | public void SetUp() 24 | { 25 | behaviorContext = new BehaviorContext(); 26 | 27 | pipelineModificationsBeforeOptimizations = new PipelineModifications(); 28 | for (int i = 0; i < PipelineDepth; i++) 29 | { 30 | pipelineModificationsBeforeOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 31 | typeof(Step1.BehaviorOptimization), i.ToString(), b => new Step1.BehaviorOptimization())); 32 | } 33 | 34 | pipelineModificationsAfterOptimizations = new PipelineModifications(); 35 | for (int i = 0; i < PipelineDepth; i++) 36 | { 37 | pipelineModificationsAfterOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 38 | typeof(Step1.BehaviorOptimization), i.ToString(), b => new Step1.BehaviorOptimization())); 39 | } 40 | 41 | pipelineBeforeOptimizations = new Step1.PipelineOptimization(null, new SettingsHolder(), 42 | pipelineModificationsBeforeOptimizations); 43 | pipelineAfterOptimizations = new PipelineOptimization(null, new SettingsHolder(), 44 | pipelineModificationsAfterOptimizations); 45 | } 46 | 47 | [Benchmark(Baseline = true)] 48 | public async Task Before() 49 | { 50 | await pipelineBeforeOptimizations.Invoke(behaviorContext); 51 | } 52 | 53 | [Benchmark] 54 | public async Task After() 55 | { 56 | await pipelineAfterOptimizations.Invoke(behaviorContext); 57 | } 58 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Step2/Step2_PipelineWarmup.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Attributes; 2 | using NServiceBus.Pipeline; 3 | 4 | namespace PipelineOptimizations.Step2; 5 | 6 | [ShortRunJob] 7 | [MemoryDiagnoser] 8 | public class Step2_PipelineWarmup 9 | { 10 | [Params(10, 20, 40)] 11 | public int PipelineDepth { get; set; } 12 | 13 | private PipelineModifications pipelineModificationsBeforeOptimizations; 14 | private PipelineModifications pipelineModificationsAfterOptimizations; 15 | 16 | [GlobalSetup] 17 | public void SetUp() 18 | { 19 | pipelineModificationsBeforeOptimizations = new PipelineModifications(); 20 | for (int i = 0; i < PipelineDepth; i++) 21 | { 22 | pipelineModificationsBeforeOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 23 | typeof(Step1.BehaviorOptimization), i.ToString(), b => new Step1.BehaviorOptimization())); 24 | } 25 | 26 | pipelineModificationsAfterOptimizations = new PipelineModifications(); 27 | for (int i = 0; i < PipelineDepth; i++) 28 | { 29 | pipelineModificationsAfterOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 30 | typeof(Step1.BehaviorOptimization), i.ToString(), b => new Step1.BehaviorOptimization())); 31 | } 32 | } 33 | 34 | [Benchmark(Baseline = true)] 35 | public Step1.PipelineOptimization Before() 36 | { 37 | var pipelineBeforeOptimizations = new Step1.PipelineOptimization(null, new SettingsHolder(), 38 | pipelineModificationsBeforeOptimizations); 39 | return pipelineBeforeOptimizations; 40 | } 41 | 42 | [Benchmark] 43 | public PipelineOptimization After() 44 | { 45 | var pipelineAfterOptimizations = new PipelineOptimization(null, new SettingsHolder(), 46 | pipelineModificationsAfterOptimizations); 47 | return pipelineAfterOptimizations; 48 | } 49 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Step3/BehaviorExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Linq.Expressions; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using FastExpressionCompiler; 6 | using NServiceBus.Pipeline; 7 | 8 | namespace PipelineOptimizations.Step3; 9 | 10 | static class BehaviorExtensions 11 | { 12 | public static Func CreatePipelineExecutionFuncWithSmugglingAndUnsafeFor(this IBehavior[] behaviors, List expressions = null) 13 | where TRootContext : IBehaviorContext => 14 | (Func)behaviors.CreatePipelineExecutionExpression(expressions); 15 | 16 | /// 17 | /// rootContext 18 | /// => GetBehavior(rootContext, 0).Invoke(rootContext, 19 | /// context1 => GetBehavior(context2, 1).Invoke(context1, 20 | /// ... 21 | /// context{N} => GetBehavior(context{N}, {N-1}).Invoke(context{N}, 22 | /// context{N+1} => TaskEx.Completed)) 23 | /// 24 | public static Delegate CreatePipelineExecutionExpression(this IBehavior[] behaviors, List expressions = null) 25 | { 26 | Delegate lambdaExpression = null; 27 | var behaviorCount = behaviors.Length - 1; 28 | // We start from the end of the list know the lambda expressions deeper in the call stack in advance 29 | for (var i = behaviorCount; i >= 0; i--) 30 | { 31 | var currentBehavior = behaviors[i]; 32 | var behaviorInterfaceType = currentBehavior.GetType().GetBehaviorInterface() ?? throw new InvalidOperationException("Behaviors must implement IBehavior"); 33 | // Select the method on the type which was implemented from the behavior interface. 34 | var methodInfo = currentBehavior.GetType().GetInterfaceMap(behaviorInterfaceType).TargetMethods.FirstOrDefault() ?? throw new InvalidOperationException("Behaviors must implement IBehavior and provide an invocation method."); 35 | 36 | var genericArguments = behaviorInterfaceType.GetGenericArguments(); 37 | var inContextType = genericArguments[0]; 38 | var outContextType = genericArguments[1]; 39 | 40 | var inContextParameter = Expression.Parameter(inContextType, $"context{i}"); 41 | 42 | if (i == behaviorCount) 43 | { 44 | var doneDelegate = CreateDoneDelegate(outContextType, i); 45 | lambdaExpression = CreateBehaviorCallDelegate(methodInfo, inContextParameter, currentBehavior.GetType(), doneDelegate, i, expressions); 46 | continue; 47 | } 48 | 49 | lambdaExpression = CreateBehaviorCallDelegate(methodInfo, inContextParameter, currentBehavior.GetType(), lambdaExpression, i, expressions); 50 | } 51 | 52 | return lambdaExpression; 53 | } 54 | 55 | /// 56 | /// context{i} => GetBehavior(context{i}, {i}).Invoke(context{i+1} => previous) 57 | /// > 58 | static Delegate CreateBehaviorCallDelegate(MethodInfo methodInfo, ParameterExpression outerContextParam, Type behaviorType, Delegate previous, int i, List expressions = null) 59 | { 60 | MethodInfo getBehaviorMethodInfo = GetBehaviorMethodInfo.MakeGenericMethod(outerContextParam.Type, behaviorType); 61 | Expression getBehaviorCallExpression = Expression.Call(null, getBehaviorMethodInfo, outerContextParam, Expression.Constant(i)); 62 | Expression body = Expression.Call(getBehaviorCallExpression, methodInfo, outerContextParam, Expression.Constant(previous)); 63 | var lambdaExpression = Expression.Lambda(body, outerContextParam); 64 | expressions?.Add(lambdaExpression); 65 | return lambdaExpression.CompileFast(); 66 | } 67 | 68 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 69 | public static TBehavior GetBehavior(TContext context, int index) 70 | where TContext : class, IBehaviorContext 71 | where TBehavior : class, IBehavior 72 | => Unsafe.As( 73 | Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(context.Extensions.Behaviors), index)); 74 | 75 | /// 76 | /// context{i} => return TaskEx.CompletedTask; 77 | /// > 78 | static Delegate CreateDoneDelegate(Type inContextType, int i) 79 | { 80 | var innerContextParam = Expression.Parameter(inContextType, $"context{i + 1}"); 81 | var doneDelegateType = typeof(Func<,>).MakeGenericType(inContextType, typeof(Task)); 82 | return Expression.Lambda(doneDelegateType, Expression.Constant(Task.CompletedTask), innerContextParam).CompileFast(); 83 | } 84 | 85 | static readonly MethodInfo GetBehaviorMethodInfo = 86 | typeof(BehaviorExtensions).GetMethod("GetBehavior")!; 87 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Step3/PipelineOptimization.cs: -------------------------------------------------------------------------------- 1 | using NServiceBus.Pipeline; 2 | 3 | namespace PipelineOptimizations.Step3; 4 | 5 | public class PipelineOptimization 6 | where TContext : IBehaviorContext 7 | { 8 | public PipelineOptimization(IBuilder builder, ReadOnlySettings settings, 9 | PipelineModifications pipelineModifications) 10 | { 11 | var coordinator = new StepRegistrationsCoordinator(pipelineModifications.Removals, 12 | pipelineModifications.Replacements); 13 | 14 | foreach (var rego in pipelineModifications.Additions.Where(x => x.IsEnabled(settings))) 15 | { 16 | coordinator.Register(rego); 17 | } 18 | 19 | // Important to keep a reference 20 | behaviors = coordinator.BuildPipelineModelFor() 21 | .Select(r => r.CreateBehaviorNew(builder)).ToArray(); 22 | 23 | pipeline = behaviors.CreatePipelineExecutionFuncWithSmugglingAndUnsafeFor(); 24 | } 25 | 26 | public Task Invoke(TContext context) 27 | { 28 | context.Extensions.Behaviors = behaviors; 29 | return pipeline(context); 30 | } 31 | 32 | // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable 33 | readonly IBehavior[] behaviors; 34 | readonly Func pipeline; 35 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Step3/Step3_PipelineException.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Attributes; 2 | using NServiceBus.Pipeline; 3 | 4 | namespace PipelineOptimizations.Step3; 5 | 6 | [ShortRunJob] 7 | [MemoryDiagnoser] 8 | public class Step3_PipelineException 9 | { 10 | [Params(10, 20, 40)] 11 | public int PipelineDepth { get; set; } 12 | 13 | private BehaviorContext behaviorContext; 14 | private PipelineModifications pipelineModificationsBeforeOptimizations; 15 | private PipelineModifications pipelineModificationsAfterOptimizations; 16 | private Step2.PipelineOptimization pipelineBeforeOptimizations; 17 | private PipelineOptimization pipelineAfterOptimizations; 18 | 19 | [GlobalSetup] 20 | public void SetUp() 21 | { 22 | behaviorContext = new BehaviorContext(); 23 | 24 | pipelineModificationsBeforeOptimizations = new PipelineModifications(); 25 | for (int i = 0; i < PipelineDepth; i++) 26 | { 27 | pipelineModificationsBeforeOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 28 | typeof(Step1.BehaviorOptimization), i.ToString(), b => new Step1.BehaviorOptimization())); 29 | } 30 | var stepdId = PipelineDepth + 1; 31 | pipelineModificationsBeforeOptimizations.Additions.Add(RegisterStep.Create(stepdId.ToString(), typeof(Throwing), "1", b => new Throwing())); 32 | 33 | pipelineModificationsAfterOptimizations = new PipelineModifications(); 34 | for (int i = 0; i < PipelineDepth; i++) 35 | { 36 | pipelineModificationsAfterOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 37 | typeof(Step1.BehaviorOptimization), i.ToString(), b => new Step1.BehaviorOptimization())); 38 | } 39 | pipelineModificationsAfterOptimizations.Additions.Add(RegisterStep.Create(stepdId.ToString(), typeof(Throwing), "1", b => new Throwing())); 40 | 41 | pipelineBeforeOptimizations = new Step2.PipelineOptimization(null, new SettingsHolder(), 42 | pipelineModificationsBeforeOptimizations); 43 | pipelineAfterOptimizations = new PipelineOptimization(null, new SettingsHolder(), 44 | pipelineModificationsAfterOptimizations); 45 | } 46 | 47 | [Benchmark(Baseline = true)] 48 | public async Task Before() 49 | { 50 | try 51 | { 52 | await pipelineBeforeOptimizations.Invoke(behaviorContext).ConfigureAwait(false); 53 | } 54 | catch (InvalidOperationException) 55 | { 56 | } 57 | } 58 | 59 | [Benchmark] 60 | public async Task After() 61 | { 62 | try 63 | { 64 | await pipelineAfterOptimizations.Invoke(behaviorContext).ConfigureAwait(false); 65 | } 66 | catch (InvalidOperationException) 67 | { 68 | } 69 | } 70 | 71 | class Throwing : Behavior 72 | { 73 | public override Task Invoke(IBehaviorContext context, Func next) 74 | { 75 | throw new InvalidOperationException(); 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Step3/Step3_PipelineExecution.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Attributes; 2 | using NServiceBus.Pipeline; 3 | 4 | namespace PipelineOptimizations.Step3; 5 | 6 | [ShortRunJob] 7 | [MemoryDiagnoser] 8 | public class Step3_PipelineExecution 9 | { 10 | [Params(10, 20, 40)] 11 | public int PipelineDepth { get; set; } 12 | 13 | private BehaviorContext behaviorContext; 14 | private PipelineModifications pipelineModificationsBeforeOptimizations; 15 | private PipelineModifications pipelineModificationsAfterOptimizations; 16 | private Step2.PipelineOptimization pipelineBeforeOptimizations; 17 | private PipelineOptimization pipelineAfterOptimizations; 18 | 19 | [GlobalSetup] 20 | public void SetUp() 21 | { 22 | behaviorContext = new BehaviorContext(); 23 | 24 | pipelineModificationsBeforeOptimizations = new PipelineModifications(); 25 | for (int i = 0; i < PipelineDepth; i++) 26 | { 27 | pipelineModificationsBeforeOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 28 | typeof(Step1.BehaviorOptimization), i.ToString(), b => new Step1.BehaviorOptimization())); 29 | } 30 | 31 | pipelineModificationsAfterOptimizations = new PipelineModifications(); 32 | for (int i = 0; i < PipelineDepth; i++) 33 | { 34 | pipelineModificationsAfterOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 35 | typeof(Step1.BehaviorOptimization), i.ToString(), b => new Step1.BehaviorOptimization())); 36 | } 37 | 38 | pipelineBeforeOptimizations = new Step2.PipelineOptimization(null, new SettingsHolder(), 39 | pipelineModificationsBeforeOptimizations); 40 | pipelineAfterOptimizations = new PipelineOptimization(null, new SettingsHolder(), 41 | pipelineModificationsAfterOptimizations); 42 | } 43 | 44 | [Benchmark(Baseline = true)] 45 | public async Task Before() 46 | { 47 | await pipelineBeforeOptimizations.Invoke(behaviorContext); 48 | } 49 | 50 | [Benchmark] 51 | public async Task After() 52 | { 53 | await pipelineAfterOptimizations.Invoke(behaviorContext); 54 | } 55 | } -------------------------------------------------------------------------------- /PipelineOptimizations/Step3/Step3_PipelineWarmup.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Attributes; 2 | using NServiceBus.Pipeline; 3 | 4 | namespace PipelineOptimizations.Step3; 5 | 6 | [ShortRunJob] 7 | [MemoryDiagnoser] 8 | public class Step3_PipelineWarmup 9 | { 10 | [Params(10, 20, 40)] 11 | public int PipelineDepth { get; set; } 12 | 13 | private PipelineModifications pipelineModificationsBeforeOptimizations; 14 | private PipelineModifications pipelineModificationsAfterOptimizations; 15 | 16 | [GlobalSetup] 17 | public void SetUp() 18 | { 19 | pipelineModificationsBeforeOptimizations = new PipelineModifications(); 20 | for (int i = 0; i < PipelineDepth; i++) 21 | { 22 | pipelineModificationsBeforeOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 23 | typeof(Step1.BehaviorOptimization), i.ToString(), b => new Step1.BehaviorOptimization())); 24 | } 25 | 26 | pipelineModificationsAfterOptimizations = new PipelineModifications(); 27 | for (int i = 0; i < PipelineDepth; i++) 28 | { 29 | pipelineModificationsAfterOptimizations.Additions.Add(RegisterStep.Create(i.ToString(), 30 | typeof(Step1.BehaviorOptimization), i.ToString(), b => new Step1.BehaviorOptimization())); 31 | } 32 | } 33 | 34 | [Benchmark(Baseline = true)] 35 | public Step2.PipelineOptimization Before() 36 | { 37 | var pipelineBeforeOptimizations = new Step2.PipelineOptimization(null, new SettingsHolder(), 38 | pipelineModificationsBeforeOptimizations); 39 | return pipelineBeforeOptimizations; 40 | } 41 | 42 | [Benchmark] 43 | public PipelineOptimization After() 44 | { 45 | var pipelineAfterOptimizations = new PipelineOptimization(null, new SettingsHolder(), 46 | pipelineModificationsAfterOptimizations); 47 | return pipelineAfterOptimizations; 48 | } 49 | } -------------------------------------------------------------------------------- /PipelinePublishV6/MyEvent.cs: -------------------------------------------------------------------------------- 1 | using NServiceBus; 2 | 3 | namespace PipelinePublishV6 4 | { 5 | public class MyEvent : IEvent 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /PipelinePublishV6/MyEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using NServiceBus; 4 | 5 | namespace PipelinePublishV6 6 | { 7 | public class MyEventHandler : IHandleMessages 8 | { 9 | public Task Handle(MyEvent message, IMessageHandlerContext context) 10 | { 11 | Console.WriteLine("Event received"); 12 | return Task.CompletedTask; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /PipelinePublishV6/PipelinePublishV6.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Release 6 | AnyCPU 7 | {7AA11012-A0C2-417D-B22E-B123DBF17947} 8 | Exe 9 | Properties 10 | PipelinePublishV6 11 | PipelinePublishV6 12 | v4.8 13 | 512 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | packages\NServiceBus.6.0.0\lib\net452\NServiceBus.Core.dll 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6BehaviorChainZoomIn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6BehaviorChainZoomIn.png -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6BehaviorChainZoomIn2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6BehaviorChainZoomIn2.png -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6BehaviorChainZoomInOptimized.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6BehaviorChainZoomInOptimized.png -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6BehaviorZoomIn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6BehaviorZoomIn.png -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6PublishCpuOverview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6PublishCpuOverview.png -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6PublishCpuOverviewFlamegraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6PublishCpuOverviewFlamegraph.png -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6PublishCpuOverviewOptimizedFlamegraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6PublishCpuOverviewOptimizedFlamegraph.png -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6PublishCpuPerfViewFlamegraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6PublishCpuPerfViewFlamegraph.png -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6PublishMemoryOverview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6PublishMemoryOverview.png -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6PublishMemoryOverviewOptimized.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6PublishMemoryOverviewOptimized.png -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6ReceiveCpuOverview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6ReceiveCpuOverview.png -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6ReceiveCpuOverviewFlamegraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6ReceiveCpuOverviewFlamegraph.png -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6ReceiveCpuOverviewOptimizedFlamegraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6ReceiveCpuOverviewOptimizedFlamegraph.png -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6ReceiveCpuPerfViewFlamegraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6ReceiveCpuPerfViewFlamegraph.png -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6ReceiveMemoryOverview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6ReceiveMemoryOverview.png -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6ReceiveMemoryOverviewOptimized.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6ReceiveMemoryOverviewOptimized.png -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6StageForkAndDisplayClasses.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6StageForkAndDisplayClasses.png -------------------------------------------------------------------------------- /PipelinePublishV6/PipelineV6StageForkAndDisplayClassesOptimized.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/PipelinePublishV6/PipelineV6StageForkAndDisplayClassesOptimized.png -------------------------------------------------------------------------------- /PipelinePublishV6/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | using NServiceBus; 5 | 6 | namespace PipelinePublishV6 7 | { 8 | internal class Program 9 | { 10 | public static async Task Main(string[] args) 11 | { 12 | var endpointConfiguration = new EndpointConfiguration("PublishSample"); 13 | endpointConfiguration.UseSerialization(); 14 | var transport = endpointConfiguration.UseTransport(); 15 | transport.Routing().RegisterPublisher(typeof(MyEvent), "PublishSample"); 16 | endpointConfiguration.UsePersistence(); 17 | endpointConfiguration.EnableInstallers(); 18 | endpointConfiguration.SendFailedMessagesTo("error"); 19 | 20 | var endpointInstance = await Endpoint.Start(endpointConfiguration); 21 | 22 | Console.WriteLine("Attach the profiler and hit ."); 23 | Console.ReadLine(); 24 | 25 | var tasks = new List(1000); 26 | for (int i = 0; i < 1000; i++) 27 | { 28 | tasks.Add(endpointInstance.Publish(new MyEvent())); 29 | } 30 | await Task.WhenAll(tasks); 31 | 32 | Console.WriteLine("Publish 1000 done. Get a snapshot"); 33 | Console.ReadLine(); 34 | 35 | tasks = new List(10000); 36 | for (int i = 0; i < 10000; i++) 37 | { 38 | tasks.Add(endpointInstance.Publish(new MyEvent())); 39 | } 40 | await Task.WhenAll(tasks); 41 | 42 | Console.WriteLine("Publish done. Hit to shut down."); 43 | Console.ReadLine(); 44 | 45 | await endpointInstance.Stop(); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /PipelinePublishV6/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("PipelinePublishV6")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("PipelinePublishV6")] 12 | [assembly: AssemblyCopyright("Copyright © 2023")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("7AA11012-A0C2-417D-B22E-B123DBF17947")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /PipelinePublishV6/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Simple/Program.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Running; 2 | 3 | var switcher = new BenchmarkSwitcher(typeof(Program).Assembly); 4 | switcher.Run(args); -------------------------------------------------------------------------------- /Simple/Simple.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net7.0 6 | enable 7 | enable 8 | true 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Simple/StringJoin.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Attributes; 2 | using BenchmarkDotNet.Configs; 3 | using BenchmarkDotNet.Diagnosers; 4 | using BenchmarkDotNet.Jobs; 5 | using System; 6 | using System.Text; 7 | using System.Linq; 8 | 9 | [SimpleJob] 10 | [MemoryDiagnoser] 11 | public class StringJoinBenchmarks { 12 | 13 | [Benchmark] 14 | public string StringJoin() { 15 | return string.Join(", ", Enumerable.Range(0, 10).Select(i => i.ToString())); 16 | } 17 | 18 | [Benchmark] 19 | public string StringBuilder() { 20 | var sb = new StringBuilder(); 21 | for (int i = 0; i < 10; i++) 22 | { 23 | sb.Append(i); 24 | sb.Append(", "); 25 | } 26 | 27 | return sb.ToString(0, sb.Length - 2); 28 | } 29 | 30 | [Benchmark] 31 | public string ValueStringBuilder() { 32 | var seperator = new ReadOnlySpan(new char[] { ',', ' '}); 33 | using var sb = new ValueStringBuilder(stackalloc char[30]); 34 | for (int i = 0; i < 10; i++) 35 | { 36 | sb.Append(i); 37 | sb.Append(seperator); 38 | } 39 | 40 | return sb.AsSpan(0, sb.Length - 2).ToString(); 41 | } 42 | } -------------------------------------------------------------------------------- /Simple/ValueStringBuilder.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Buffers; 5 | using System.Diagnostics; 6 | using System.Runtime.CompilerServices; 7 | using System.Runtime.InteropServices; 8 | 9 | #nullable enable 10 | 11 | namespace System.Text 12 | { 13 | internal ref partial struct ValueStringBuilder 14 | { 15 | private char[]? _arrayToReturnToPool; 16 | private Span _chars; 17 | private int _pos; 18 | 19 | public ValueStringBuilder(Span initialBuffer) 20 | { 21 | _arrayToReturnToPool = null; 22 | _chars = initialBuffer; 23 | _pos = 0; 24 | } 25 | 26 | public ValueStringBuilder(int initialCapacity) 27 | { 28 | _arrayToReturnToPool = ArrayPool.Shared.Rent(initialCapacity); 29 | _chars = _arrayToReturnToPool; 30 | _pos = 0; 31 | } 32 | 33 | public int Length 34 | { 35 | get => _pos; 36 | set 37 | { 38 | Debug.Assert(value >= 0); 39 | Debug.Assert(value <= _chars.Length); 40 | _pos = value; 41 | } 42 | } 43 | 44 | public int Capacity => _chars.Length; 45 | 46 | public void EnsureCapacity(int capacity) 47 | { 48 | // This is not expected to be called this with negative capacity 49 | Debug.Assert(capacity >= 0); 50 | 51 | // If the caller has a bug and calls this with negative capacity, make sure to call Grow to throw an exception. 52 | if ((uint)capacity > (uint)_chars.Length) 53 | Grow(capacity - _pos); 54 | } 55 | 56 | /// 57 | /// Get a pinnable reference to the builder. 58 | /// Does not ensure there is a null char after 59 | /// This overload is pattern matched in the C# 7.3+ compiler so you can omit 60 | /// the explicit method call, and write eg "fixed (char* c = builder)" 61 | /// 62 | public ref char GetPinnableReference() 63 | { 64 | return ref MemoryMarshal.GetReference(_chars); 65 | } 66 | 67 | /// 68 | /// Get a pinnable reference to the builder. 69 | /// 70 | /// Ensures that the builder has a null char after 71 | public ref char GetPinnableReference(bool terminate) 72 | { 73 | if (terminate) 74 | { 75 | EnsureCapacity(Length + 1); 76 | _chars[Length] = '\0'; 77 | } 78 | return ref MemoryMarshal.GetReference(_chars); 79 | } 80 | 81 | public ref char this[int index] 82 | { 83 | get 84 | { 85 | Debug.Assert(index < _pos); 86 | return ref _chars[index]; 87 | } 88 | } 89 | 90 | public override string ToString() 91 | { 92 | string s = _chars.Slice(0, _pos).ToString(); 93 | Dispose(); 94 | return s; 95 | } 96 | 97 | /// Returns the underlying storage of the builder. 98 | public Span RawChars => _chars; 99 | 100 | /// 101 | /// Returns a span around the contents of the builder. 102 | /// 103 | /// Ensures that the builder has a null char after 104 | public ReadOnlySpan AsSpan(bool terminate) 105 | { 106 | if (terminate) 107 | { 108 | EnsureCapacity(Length + 1); 109 | _chars[Length] = '\0'; 110 | } 111 | return _chars.Slice(0, _pos); 112 | } 113 | 114 | public ReadOnlySpan AsSpan() => _chars.Slice(0, _pos); 115 | public ReadOnlySpan AsSpan(int start) => _chars.Slice(start, _pos - start); 116 | public ReadOnlySpan AsSpan(int start, int length) => _chars.Slice(start, length); 117 | 118 | public bool TryCopyTo(Span destination, out int charsWritten) 119 | { 120 | if (_chars.Slice(0, _pos).TryCopyTo(destination)) 121 | { 122 | charsWritten = _pos; 123 | Dispose(); 124 | return true; 125 | } 126 | else 127 | { 128 | charsWritten = 0; 129 | Dispose(); 130 | return false; 131 | } 132 | } 133 | 134 | public void Insert(int index, char value, int count) 135 | { 136 | if (_pos > _chars.Length - count) 137 | { 138 | Grow(count); 139 | } 140 | 141 | int remaining = _pos - index; 142 | _chars.Slice(index, remaining).CopyTo(_chars.Slice(index + count)); 143 | _chars.Slice(index, count).Fill(value); 144 | _pos += count; 145 | } 146 | 147 | public void Insert(int index, string? s) 148 | { 149 | if (s == null) 150 | { 151 | return; 152 | } 153 | 154 | int count = s.Length; 155 | 156 | if (_pos > (_chars.Length - count)) 157 | { 158 | Grow(count); 159 | } 160 | 161 | int remaining = _pos - index; 162 | _chars.Slice(index, remaining).CopyTo(_chars.Slice(index + count)); 163 | s 164 | #if !NETCOREAPP 165 | .AsSpan() 166 | #endif 167 | .CopyTo(_chars.Slice(index)); 168 | _pos += count; 169 | } 170 | 171 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 172 | public void Append(char c) 173 | { 174 | int pos = _pos; 175 | Span chars = _chars; 176 | if ((uint)pos < (uint)chars.Length) 177 | { 178 | chars[pos] = c; 179 | _pos = pos + 1; 180 | } 181 | else 182 | { 183 | GrowAndAppend(c); 184 | } 185 | } 186 | 187 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 188 | public void Append(string? s) 189 | { 190 | if (s == null) 191 | { 192 | return; 193 | } 194 | 195 | int pos = _pos; 196 | if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 197 | { 198 | _chars[pos] = s[0]; 199 | _pos = pos + 1; 200 | } 201 | else 202 | { 203 | AppendSlow(s); 204 | } 205 | } 206 | 207 | private void AppendSlow(string s) 208 | { 209 | int pos = _pos; 210 | if (pos > _chars.Length - s.Length) 211 | { 212 | Grow(s.Length); 213 | } 214 | 215 | s 216 | #if !NETCOREAPP 217 | .AsSpan() 218 | #endif 219 | .CopyTo(_chars.Slice(pos)); 220 | _pos += s.Length; 221 | } 222 | 223 | public void Append(char c, int count) 224 | { 225 | if (_pos > _chars.Length - count) 226 | { 227 | Grow(count); 228 | } 229 | 230 | Span dst = _chars.Slice(_pos, count); 231 | for (int i = 0; i < dst.Length; i++) 232 | { 233 | dst[i] = c; 234 | } 235 | _pos += count; 236 | } 237 | 238 | public unsafe void Append(char* value, int length) 239 | { 240 | int pos = _pos; 241 | if (pos > _chars.Length - length) 242 | { 243 | Grow(length); 244 | } 245 | 246 | Span dst = _chars.Slice(_pos, length); 247 | for (int i = 0; i < dst.Length; i++) 248 | { 249 | dst[i] = *value++; 250 | } 251 | _pos += length; 252 | } 253 | 254 | public void Append(ReadOnlySpan value) 255 | { 256 | int pos = _pos; 257 | if (pos > _chars.Length - value.Length) 258 | { 259 | Grow(value.Length); 260 | } 261 | 262 | value.CopyTo(_chars.Slice(_pos)); 263 | _pos += value.Length; 264 | } 265 | 266 | public void Append(int value) => AppendSpanFormattable(value); 267 | 268 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 269 | public Span AppendSpan(int length) 270 | { 271 | int origPos = _pos; 272 | if (origPos > _chars.Length - length) 273 | { 274 | Grow(length); 275 | } 276 | 277 | _pos = origPos + length; 278 | return _chars.Slice(origPos, length); 279 | } 280 | 281 | [MethodImpl(MethodImplOptions.NoInlining)] 282 | private void GrowAndAppend(char c) 283 | { 284 | Grow(1); 285 | Append(c); 286 | } 287 | 288 | private void AppendSpanFormattable(T value) where T : ISpanFormattable 289 | { 290 | Debug.Assert(typeof(T).Assembly.Equals(typeof(object).Assembly), "Implementation trusts the results of TryFormat because T is expected to be something known"); 291 | 292 | Span dst = _chars.Slice(_pos); 293 | if (value.TryFormat(dst, out int charsWritten, format: default, provider: null)) 294 | { 295 | _pos += charsWritten; 296 | return; 297 | } 298 | 299 | Append(value.ToString()); 300 | } 301 | 302 | /// 303 | /// Resize the internal buffer either by doubling current buffer size or 304 | /// by adding to 305 | /// whichever is greater. 306 | /// 307 | /// 308 | /// Number of chars requested beyond current position. 309 | /// 310 | [MethodImpl(MethodImplOptions.NoInlining)] 311 | private void Grow(int additionalCapacityBeyondPos) 312 | { 313 | Debug.Assert(additionalCapacityBeyondPos > 0); 314 | Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 315 | 316 | const uint ArrayMaxLength = 0x7FFFFFC7; // same as Array.MaxLength 317 | 318 | // Increase to at least the required size (_pos + additionalCapacityBeyondPos), but try 319 | // to double the size if possible, bounding the doubling to not go beyond the max array length. 320 | int newCapacity = (int)Math.Max( 321 | (uint)(_pos + additionalCapacityBeyondPos), 322 | Math.Min((uint)_chars.Length * 2, ArrayMaxLength)); 323 | 324 | // Make sure to let Rent throw an exception if the caller has a bug and the desired capacity is negative. 325 | // This could also go negative if the actual required length wraps around. 326 | char[] poolArray = ArrayPool.Shared.Rent(newCapacity); 327 | 328 | _chars.Slice(0, _pos).CopyTo(poolArray); 329 | 330 | char[]? toReturn = _arrayToReturnToPool; 331 | _chars = _arrayToReturnToPool = poolArray; 332 | if (toReturn != null) 333 | { 334 | ArrayPool.Shared.Return(toReturn); 335 | } 336 | } 337 | 338 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 339 | public void Dispose() 340 | { 341 | char[]? toReturn = _arrayToReturnToPool; 342 | this = default; // for safety, to avoid using pooled array if this instance is erroneously appended to again 343 | if (toReturn != null) 344 | { 345 | ArrayPool.Shared.Return(toReturn); 346 | } 347 | } 348 | } 349 | } 350 | -------------------------------------------------------------------------------- /images/053b96864557636a9d4433d47a715e02: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/053b96864557636a9d4433d47a715e02 -------------------------------------------------------------------------------- /images/0b94d81807e4f45e8a18b78aabbf842b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/0b94d81807e4f45e8a18b78aabbf842b.png -------------------------------------------------------------------------------- /images/1928349fd5404a17561f40017721c87b.svg: -------------------------------------------------------------------------------- 1 | 2 | NServiceBus PipelineNServiceBus PipelineNServiceBus TransportNServiceBus TransportMSMQMSMQText is not SVG - cannot display -------------------------------------------------------------------------------- /images/19d975b350aaebbbfca0a89ad63802d6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/19d975b350aaebbbfca0a89ad63802d6.png -------------------------------------------------------------------------------- /images/202b4689a8d7f41ddff962836c7c14a2.svg: -------------------------------------------------------------------------------- 1 | 2 | NServiceBus PipelineNServiceBus PipelineNServiceBus TransportNServiceBus TransportAzure.Messaging.ServiceBusAzure.Messaging.ServiceBusMicrosoft.Azure.AmqpMicrosoft.Azure.AmqpText is not SVG - cannot display -------------------------------------------------------------------------------- /images/2526187f700b13dc833f74f3837c97a2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/2526187f700b13dc833f74f3837c97a2.gif -------------------------------------------------------------------------------- /images/34389925f86fde6a2d8d861a9d82c0f0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/34389925f86fde6a2d8d861a9d82c0f0.png -------------------------------------------------------------------------------- /images/348e079793223114e33ffc101d4b78ef: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/348e079793223114e33ffc101d4b78ef -------------------------------------------------------------------------------- /images/3753e4d0befe16ffa757d21e8a6ee624.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/3753e4d0befe16ffa757d21e8a6ee624.png -------------------------------------------------------------------------------- /images/383a4c4e4d66b4be3501e8543c5f5c58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/383a4c4e4d66b4be3501e8543c5f5c58.png -------------------------------------------------------------------------------- /images/3ec66a7441fbd06e36b18a3f305b6fd8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/3ec66a7441fbd06e36b18a3f305b6fd8 -------------------------------------------------------------------------------- /images/40a08f8157634e8024628f4faa578215.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/40a08f8157634e8024628f4faa578215.png -------------------------------------------------------------------------------- /images/50cc30602a667e6393392291adc842d9.svg: -------------------------------------------------------------------------------- 1 | 2 | QueueQueueCodeCodeText is not SVG - cannot display -------------------------------------------------------------------------------- /images/56c42038c4b5aefc6858fe7f22201239.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/56c42038c4b5aefc6858fe7f22201239.png -------------------------------------------------------------------------------- /images/5b976ee516b4bf1f21e77082c48075e2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/5b976ee516b4bf1f21e77082c48075e2 -------------------------------------------------------------------------------- /images/5f4516cbce1b6216863d7e7f715176eb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/5f4516cbce1b6216863d7e7f715176eb.jpg -------------------------------------------------------------------------------- /images/611f47a787199a4b307fa850a6799f66.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/611f47a787199a4b307fa850a6799f66.png -------------------------------------------------------------------------------- /images/65dd44daffbd93cb0aa79054657d0fb6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/65dd44daffbd93cb0aa79054657d0fb6.png -------------------------------------------------------------------------------- /images/6bcab76360da0344e65f4d08a696706e.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/6bcab76360da0344e65f4d08a696706e.gif -------------------------------------------------------------------------------- /images/7e85e80a6c1c3add28e6563f9de0ee93.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/7e85e80a6c1c3add28e6563f9de0ee93.jpg -------------------------------------------------------------------------------- /images/8509e92cdec2f61f8b253f31bcdf4b20: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/8509e92cdec2f61f8b253f31bcdf4b20 -------------------------------------------------------------------------------- /images/8a9347042ced3a4d29a4534f1cd4cef7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/8a9347042ced3a4d29a4534f1cd4cef7.gif -------------------------------------------------------------------------------- /images/8c801f6d3d8ed48e88b878868191b4dd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/8c801f6d3d8ed48e88b878868191b4dd.png -------------------------------------------------------------------------------- /images/8d775a6f7fa6f4a11375067c53a618bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/8d775a6f7fa6f4a11375067c53a618bb.png -------------------------------------------------------------------------------- /images/8e3a27607012f78e399a6eaf90e57cd9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/8e3a27607012f78e399a6eaf90e57cd9.gif -------------------------------------------------------------------------------- /images/9614058d0ca65d9baea3e149d35db0f9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/9614058d0ca65d9baea3e149d35db0f9.gif -------------------------------------------------------------------------------- /images/98cd3e80810f41626f293907a269c75d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/98cd3e80810f41626f293907a269c75d -------------------------------------------------------------------------------- /images/9aac330bd57a1ecfd0c90320968af3ce.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/9aac330bd57a1ecfd0c90320968af3ce.gif -------------------------------------------------------------------------------- /images/a7397e6e6bf45f949df6fb38ee262ff2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/a7397e6e6bf45f949df6fb38ee262ff2.png -------------------------------------------------------------------------------- /images/aa1d92385b8aca6d2a6e529a3912242d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/aa1d92385b8aca6d2a6e529a3912242d -------------------------------------------------------------------------------- /images/ab2d29e1e882e268c01ab37febcf033b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/ab2d29e1e882e268c01ab37febcf033b.png -------------------------------------------------------------------------------- /images/ad50cf7dea44b686dcc0aeb85ad96b48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/ad50cf7dea44b686dcc0aeb85ad96b48.png -------------------------------------------------------------------------------- /images/b16407686970500b8f14d9fc064a29f6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/b16407686970500b8f14d9fc064a29f6 -------------------------------------------------------------------------------- /images/b17cf7d9ae77288175395ad472bb0b0c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/b17cf7d9ae77288175395ad472bb0b0c -------------------------------------------------------------------------------- /images/b69e2d887d50a17abec28a894d63641b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/b69e2d887d50a17abec28a894d63641b.png -------------------------------------------------------------------------------- /images/bcc35ca335328fc8edbd703aa452e2fe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/bcc35ca335328fc8edbd703aa452e2fe.png -------------------------------------------------------------------------------- /images/bd90452a5153975854bda80fc2f74767.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/bd90452a5153975854bda80fc2f74767.png -------------------------------------------------------------------------------- /images/be2d7b2dbd167d401b3d0c2bc865072b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/be2d7b2dbd167d401b3d0c2bc865072b.png -------------------------------------------------------------------------------- /images/bf682c86a581d9d240d18972025c9b71.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/bf682c86a581d9d240d18972025c9b71.png -------------------------------------------------------------------------------- /images/c29bf8f8a323c227ab5ea8a8d1b31472.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/c29bf8f8a323c227ab5ea8a8d1b31472.gif -------------------------------------------------------------------------------- /images/c49e53dc5aacc0806bda9ba2ff96302e: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/c49e53dc5aacc0806bda9ba2ff96302e -------------------------------------------------------------------------------- /images/ca359274720dc037d1fcdc9f83d0195b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/ca359274720dc037d1fcdc9f83d0195b.png -------------------------------------------------------------------------------- /images/cb8825c23f5c49d80be4b641d43a3da9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/cb8825c23f5c49d80be4b641d43a3da9.png -------------------------------------------------------------------------------- /images/d690b3fc2a94a1f83f9cdb9cf75bd80d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/d690b3fc2a94a1f83f9cdb9cf75bd80d.png -------------------------------------------------------------------------------- /images/dc58df196a8a8efd1baffcfd03538f50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/dc58df196a8a8efd1baffcfd03538f50.png -------------------------------------------------------------------------------- /images/fa8524b6df89e3e7798dac000345b70b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/fa8524b6df89e3e7798dac000345b70b.png -------------------------------------------------------------------------------- /images/fc2b634e166d5e29b1ac1912bc331848: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/images/fc2b634e166d5e29b1ac1912bc331848 -------------------------------------------------------------------------------- /lib/fonts/asul/asul-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/asul/asul-bold.woff -------------------------------------------------------------------------------- /lib/fonts/asul/asul-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/asul/asul-regular.woff -------------------------------------------------------------------------------- /lib/fonts/asul/asul.css: -------------------------------------------------------------------------------- 1 | /* Generated by Font Squirrel (http://www.fontsquirrel.com) on May 10, 2013 */ 2 | 3 | @font-face { 4 | font-family: 'Asul'; 5 | font-style: normal; 6 | font-weight: 400; 7 | font-display: auto; 8 | src: url('asul-regular.woff') format('woff'); 9 | } 10 | @font-face { 11 | font-family: 'Asul'; 12 | font-style: normal; 13 | font-weight: 700; 14 | font-display: auto; 15 | src: url('asul-bold.woff') format('woff'); 16 | } 17 | -------------------------------------------------------------------------------- /lib/fonts/cabinsketch/cabinsketch-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/cabinsketch/cabinsketch-bold.woff -------------------------------------------------------------------------------- /lib/fonts/cabinsketch/cabinsketch-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/cabinsketch/cabinsketch-regular.woff -------------------------------------------------------------------------------- /lib/fonts/cabinsketch/cabinsketch.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Cabin Sketch'; 3 | font-style: normal; 4 | font-weight: 400; 5 | font-display: auto; 6 | src: url('cabinsketch-regular.woff') format('woff'); 7 | } 8 | @font-face { 9 | font-family: 'Cabin Sketch'; 10 | font-style: normal; 11 | font-weight: 700; 12 | font-display: auto; 13 | src: url('cabinsketch-bold.woff') format('woff'); 14 | } -------------------------------------------------------------------------------- /lib/fonts/josefinsans/josefinsans-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/josefinsans/josefinsans-bold.woff -------------------------------------------------------------------------------- /lib/fonts/josefinsans/josefinsans-bolditalic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/josefinsans/josefinsans-bolditalic.woff -------------------------------------------------------------------------------- /lib/fonts/josefinsans/josefinsans-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/josefinsans/josefinsans-italic.woff -------------------------------------------------------------------------------- /lib/fonts/josefinsans/josefinsans-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/josefinsans/josefinsans-regular.woff -------------------------------------------------------------------------------- /lib/fonts/josefinsans/josefinsans.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Josefin Sans'; 3 | font-style: normal; 4 | font-weight: 400; 5 | font-display: auto; 6 | src: url('josefinsans-regular.woff') format('woff'); 7 | } 8 | @font-face { 9 | font-family: 'Josefin Sans'; 10 | font-style: normal; 11 | font-weight: 700; 12 | font-display: auto; 13 | src: url('josefinsans-bold.woff') format('woff'); 14 | } 15 | @font-face { 16 | font-family: 'Josefin Sans'; 17 | font-style: italic; 18 | font-weight: 400; 19 | font-display: auto; 20 | src: url('josefinsans-italic.woff') format('woff'); 21 | } 22 | @font-face { 23 | font-family: 'Josefin Sans'; 24 | font-style: italic; 25 | font-weight: 700; 26 | font-display: auto; 27 | src: url('josefinsans-bolditalic.woff') format('woff'); 28 | } 29 | -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_AMS-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_AMS-Regular.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_Caligraphic-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_Caligraphic-Bold.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_Caligraphic-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_Caligraphic-Regular.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_Fraktur-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_Fraktur-Bold.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_Fraktur-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_Fraktur-Regular.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_Main-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_Main-Bold.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_Main-BoldItalic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_Main-BoldItalic.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_Main-Italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_Main-Italic.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_Main-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_Main-Regular.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_Math-BoldItalic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_Math-BoldItalic.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_Math-Italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_Math-Italic.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_Math-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_Math-Regular.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_SansSerif-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_SansSerif-Bold.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_SansSerif-Italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_SansSerif-Italic.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_SansSerif-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_SansSerif-Regular.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_Script-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_Script-Regular.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_Size1-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_Size1-Regular.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_Size2-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_Size2-Regular.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_Size3-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_Size3-Regular.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_Size4-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_Size4-Regular.woff -------------------------------------------------------------------------------- /lib/fonts/katex/KaTeX_Typewriter-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/katex/KaTeX_Typewriter-Regular.woff -------------------------------------------------------------------------------- /lib/fonts/lato/lato-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/lato/lato-bold.woff -------------------------------------------------------------------------------- /lib/fonts/lato/lato-bolditalic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/lato/lato-bolditalic.woff -------------------------------------------------------------------------------- /lib/fonts/lato/lato-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/lato/lato-italic.woff -------------------------------------------------------------------------------- /lib/fonts/lato/lato-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/lato/lato-regular.woff -------------------------------------------------------------------------------- /lib/fonts/lato/lato.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Lato'; 3 | font-style: normal; 4 | font-weight: 400; 5 | font-display: auto; 6 | src: url('lato-regular.woff') format('woff'); 7 | } 8 | @font-face { 9 | font-family: 'Lato'; 10 | font-style: normal; 11 | font-weight: 700; 12 | font-display: auto; 13 | src: url('lato-bold.woff') format('woff'); 14 | } 15 | @font-face { 16 | font-family: 'Lato'; 17 | font-style: italic; 18 | font-weight: 400; 19 | font-display: auto; 20 | src: url('lato-italic.woff') format('woff'); 21 | } 22 | @font-face { 23 | font-family: 'Lato'; 24 | font-style: italic; 25 | font-weight: 700; 26 | font-display: auto; 27 | src: url('lato-bolditalic.woff') format('woff'); 28 | } 29 | -------------------------------------------------------------------------------- /lib/fonts/league/league_gothic.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'League Gothic'; 3 | font-weight: normal; 4 | font-style: normal; 5 | font-display: auto; 6 | 7 | src: url('league_gothic.woff') format('woff'); 8 | } -------------------------------------------------------------------------------- /lib/fonts/league/league_gothic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/league/league_gothic.woff -------------------------------------------------------------------------------- /lib/fonts/league/league_gothic_license: -------------------------------------------------------------------------------- 1 | SIL Open Font License (OFL) 2 | http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL 3 | -------------------------------------------------------------------------------- /lib/fonts/merriweathersans/merriweathersans-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/merriweathersans/merriweathersans-bold.woff -------------------------------------------------------------------------------- /lib/fonts/merriweathersans/merriweathersans-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/merriweathersans/merriweathersans-regular.woff -------------------------------------------------------------------------------- /lib/fonts/merriweathersans/merriweathersans.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Merriweather Sans'; 3 | font-style: normal; 4 | font-weight: 400; 5 | font-display: auto; 6 | src: url('merriweathersans-regular.woff') format('woff'); 7 | } 8 | @font-face { 9 | font-family: 'Merriweather Sans'; 10 | font-style: normal; 11 | font-weight: 700; 12 | font-display: auto; 13 | src: url('merriweathersans-bold.woff') format('woff'); 14 | } 15 | -------------------------------------------------------------------------------- /lib/fonts/montserrat/montserrat-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/montserrat/montserrat-bold.woff -------------------------------------------------------------------------------- /lib/fonts/montserrat/montserrat-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/montserrat/montserrat-regular.woff -------------------------------------------------------------------------------- /lib/fonts/montserrat/montserrat.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Montserrat'; 3 | font-style: normal; 4 | font-weight: 400; 5 | font-display: auto; 6 | src: url('montserrat-regular.woff') format('woff'); 7 | } 8 | @font-face { 9 | font-family: 'Montserrat'; 10 | font-style: normal; 11 | font-weight: 700; 12 | font-display: auto; 13 | src: url('montserrat-bold.woff') format('woff'); 14 | } 15 | -------------------------------------------------------------------------------- /lib/fonts/newscycle/newscycle-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/newscycle/newscycle-bold.woff -------------------------------------------------------------------------------- /lib/fonts/newscycle/newscycle-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/newscycle/newscycle-regular.woff -------------------------------------------------------------------------------- /lib/fonts/newscycle/newscycle.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'News Cycle'; 3 | font-style: normal; 4 | font-weight: 400; 5 | font-display: auto; 6 | src: url('newscycle-regular.woff') format('woff'); 7 | } 8 | @font-face { 9 | font-family: 'News Cycle'; 10 | font-style: normal; 11 | font-weight: 700; 12 | font-display: auto; 13 | src: url('newscycle-bold.woff') format('woff'); 14 | } 15 | -------------------------------------------------------------------------------- /lib/fonts/opensans/opensans-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/opensans/opensans-bold.woff -------------------------------------------------------------------------------- /lib/fonts/opensans/opensans-bolditalic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/opensans/opensans-bolditalic.woff -------------------------------------------------------------------------------- /lib/fonts/opensans/opensans-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/opensans/opensans-italic.woff -------------------------------------------------------------------------------- /lib/fonts/opensans/opensans-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/opensans/opensans-regular.woff -------------------------------------------------------------------------------- /lib/fonts/opensans/opensans.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Open Sans'; 3 | font-style: normal; 4 | font-weight: 400; 5 | font-display: auto; 6 | src: url('opensans-regular.woff') format('woff'); 7 | } 8 | @font-face { 9 | font-family: 'Open Sans'; 10 | font-style: normal; 11 | font-weight: 700; 12 | font-display: auto; 13 | src: url('opensans-bold.woff') format('woff'); 14 | } 15 | @font-face { 16 | font-family: 'Open Sans'; 17 | font-style: italic; 18 | font-weight: 400; 19 | font-display: auto; 20 | src: url('opensans-italic.woff') format('woff'); 21 | } 22 | @font-face { 23 | font-family: 'Open Sans'; 24 | font-style: italic; 25 | font-weight: 700; 26 | font-display: auto; 27 | src: url('opensans-bolditalic.woff') format('woff'); 28 | } 29 | -------------------------------------------------------------------------------- /lib/fonts/overpass/overpass-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/overpass/overpass-bold.woff -------------------------------------------------------------------------------- /lib/fonts/overpass/overpass-light.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/overpass/overpass-light.woff -------------------------------------------------------------------------------- /lib/fonts/overpass/overpass-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/overpass/overpass-regular.woff -------------------------------------------------------------------------------- /lib/fonts/overpass/overpass.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Overpass'; 3 | font-style: normal; 4 | font-weight: bold; 5 | font-display: auto; 6 | src: url('overpass-bold.woff') format('woff'); 7 | } 8 | 9 | @font-face { 10 | font-family: 'Overpass'; 11 | font-style: normal; 12 | font-weight: 500; 13 | font-display: auto; 14 | src: url('overpass-regular.woff') format('woff'); 15 | } 16 | 17 | @font-face { 18 | font-family: 'Overpass'; 19 | font-style: normal; 20 | font-weight: normal; 21 | font-display: auto; 22 | src: url('overpass-light.woff') format('woff'); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /lib/fonts/overpass2/overpass2-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/overpass2/overpass2-bold.woff -------------------------------------------------------------------------------- /lib/fonts/overpass2/overpass2-bolditalic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/overpass2/overpass2-bolditalic.woff -------------------------------------------------------------------------------- /lib/fonts/overpass2/overpass2-extralight.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/overpass2/overpass2-extralight.woff -------------------------------------------------------------------------------- /lib/fonts/overpass2/overpass2-extralightitalic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/overpass2/overpass2-extralightitalic.woff -------------------------------------------------------------------------------- /lib/fonts/overpass2/overpass2-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/overpass2/overpass2-italic.woff -------------------------------------------------------------------------------- /lib/fonts/overpass2/overpass2-light.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/overpass2/overpass2-light.woff -------------------------------------------------------------------------------- /lib/fonts/overpass2/overpass2-lightitalic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/overpass2/overpass2-lightitalic.woff -------------------------------------------------------------------------------- /lib/fonts/overpass2/overpass2-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/overpass2/overpass2-regular.woff -------------------------------------------------------------------------------- /lib/fonts/overpass2/overpass2.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Overpass 2'; 3 | font-style: normal; 4 | font-weight: 700; 5 | font-display: auto; 6 | src: url('overpass2-bold.woff') format('woff'); 7 | } 8 | 9 | @font-face { 10 | font-family: 'Overpass 2'; 11 | font-style: italic; 12 | font-weight: 700; 13 | font-display: auto; 14 | src: url('overpass2-bolditalic.woff') format('woff'); 15 | } 16 | 17 | @font-face { 18 | font-family: 'Overpass 2'; 19 | font-style: normal; 20 | font-weight: 500; 21 | font-display: auto; 22 | src: url('overpass2-regular.woff') format('woff'); 23 | } 24 | 25 | @font-face { 26 | font-family: 'Overpass 2'; 27 | font-style: italic; 28 | font-weight: 500; 29 | font-display: auto; 30 | src: url('overpass2-italic.woff') format('woff'); 31 | } 32 | 33 | @font-face { 34 | font-family: 'Overpass 2'; 35 | font-style: normal; 36 | font-weight: normal; 37 | font-display: auto; 38 | src: url('overpass2-light.woff') format('woff'); 39 | } 40 | 41 | @font-face { 42 | font-family: 'Overpass 2'; 43 | font-style: italic; 44 | font-weight: normal; 45 | font-display: auto; 46 | src: url('overpass2-lightitalic.woff') format('woff'); 47 | } 48 | 49 | @font-face { 50 | font-family: 'Overpass 2'; 51 | font-style: normal; 52 | font-weight: 300; 53 | font-display: auto; 54 | src: url('overpass2-extralight.woff') format('woff'); 55 | } 56 | 57 | @font-face { 58 | font-family: 'Overpass 2'; 59 | font-style: italic; 60 | font-weight: 300; 61 | font-display: auto; 62 | src: url('overpass2-extralightitalic.woff') format('woff'); 63 | } -------------------------------------------------------------------------------- /lib/fonts/oxygen/oxygen-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/oxygen/oxygen-bold.woff -------------------------------------------------------------------------------- /lib/fonts/oxygen/oxygen-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/oxygen/oxygen-regular.woff -------------------------------------------------------------------------------- /lib/fonts/oxygen/oxygen.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Oxygen'; 3 | font-style: normal; 4 | font-weight: 400; 5 | font-display: auto; 6 | src: url('oxygen-regular.woff') format('woff'); 7 | } 8 | @font-face { 9 | font-family: 'Oxygen'; 10 | font-style: normal; 11 | font-weight: 700; 12 | font-display: auto; 13 | src: url('oxygen-bold.woff') format('woff'); 14 | } 15 | -------------------------------------------------------------------------------- /lib/fonts/quicksand/quicksand-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/quicksand/quicksand-bold.woff -------------------------------------------------------------------------------- /lib/fonts/quicksand/quicksand-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/lib/fonts/quicksand/quicksand-regular.woff -------------------------------------------------------------------------------- /lib/fonts/quicksand/quicksand.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Quicksand'; 3 | font-style: normal; 4 | font-weight: 400; 5 | font-display: auto; 6 | src: url('quicksand-regular.woff') format('woff'); 7 | } 8 | @font-face { 9 | font-family: 'Quicksand'; 10 | font-style: normal; 11 | font-weight: 700; 12 | font-display: auto; 13 | src: url('quicksand-bold.woff') format('woff'); 14 | } 15 | -------------------------------------------------------------------------------- /logitech_spotlight_revealjs.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Logitech Spotlight (Left Arrow to Shift+Spacebar and Right Arrow to Spacebar for Reveal.js", 3 | "manipulators": [ 4 | { 5 | "conditions": [ 6 | { 7 | "identifiers": [ 8 | { 9 | "product_id": 46339, 10 | "vendor_id": 1133 11 | } 12 | ], 13 | "type": "device_if" 14 | } 15 | ], 16 | "from": { 17 | "key_code": "right_arrow", 18 | "modifiers": { 19 | "optional": [ 20 | "any" 21 | ] 22 | } 23 | }, 24 | "to": [ 25 | { 26 | "key_code": "spacebar", 27 | "modifiers": [] 28 | } 29 | ], 30 | "type": "basic" 31 | }, 32 | { 33 | "conditions": [ 34 | { 35 | "identifiers": [ 36 | { 37 | "product_id": 46339, 38 | "vendor_id": 1133 39 | } 40 | ], 41 | "type": "device_if" 42 | } 43 | ], 44 | "from": { 45 | "key_code": "left_arrow", 46 | "modifiers": { 47 | "optional": [ 48 | "any" 49 | ] 50 | } 51 | }, 52 | "to": [ 53 | { 54 | "key_code": "spacebar", 55 | "modifiers": [ 56 | "left_shift" 57 | ] 58 | } 59 | ], 60 | "type": "basic" 61 | } 62 | ] 63 | } -------------------------------------------------------------------------------- /slides.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmarbach/BeyondSimpleBenchmarks/a265069eb8a3924ddbbdebecbdcb3cbc62e3d6d2/slides.pdf -------------------------------------------------------------------------------- /slides.sh: -------------------------------------------------------------------------------- 1 | 2 | rm -R ./images/ 3 | rm -R ./lib/ 4 | mkdir ./images 5 | cp -R ~/Dropbox/Apps/Slides\ App/the-performance-loopa-practical-guide-to-profiling-and-benchmarking/* ./images/ 6 | cp -R ~/Dropbox/Apps/Slides\ App/the-performance-loopa-practical-guide-to-profiling-and-benchmarking.html ./index.html 7 | cp -R ~/Dropbox/Apps/Slides\ App/lib ./lib 8 | awk '{gsub(/the-performance-loopa-practical-guide-to-profiling-and-benchmarking/, "images"); print}' index.html > index2.html 9 | mv -f index2.html index.html --------------------------------------------------------------------------------
18 | /// rootContext 19 | /// => behavior1.Invoke(rootContext, 20 | /// context1 => behavior2.Invoke(context1, 21 | /// ... 22 | /// context{N} => behavior{N}.Invoke(context{N}, 23 | /// context{N+1} => TaskEx.Completed)) 24 | ///
69 | /// context{i} => behavior.Invoke(context{i}, context{i+1} => previous) 70 | ///
80 | /// context{i} => return TaskEx.CompletedTask; 81 | ///
17 | /// rootContext 18 | /// => behavior1.Invoke(rootContext, 19 | /// context1 => behavior2.Invoke(context1, 20 | /// ... 21 | /// context{N} => behavior{N}.Invoke(context{N}, 22 | /// context{N+1} => TaskEx.Completed)) 23 | ///
66 | /// context{i} => behavior.Invoke(context{i}, context{i+1} => previous) 67 | ///
83 | /// context{i} => return TaskEx.CompletedTask; 84 | ///
17 | /// rootContext 18 | /// => GetBehavior(rootContext, 0).Invoke(rootContext, 19 | /// context1 => GetBehavior(context2, 1).Invoke(context1, 20 | /// ... 21 | /// context{N} => GetBehavior(context{N}, {N-1}).Invoke(context{N}, 22 | /// context{N+1} => TaskEx.Completed)) 23 | ///
56 | /// context{i} => GetBehavior(context{i}, {i}).Invoke(context{i+1} => previous) 57 | ///
76 | /// context{i} => return TaskEx.CompletedTask; 77 | ///