github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/examples/dotnet/README.md (about) 1 # .NET Examples 2 3 The directory contains examples of how to run Pyroscop to profile .NET applications in Docker containers. 4 5 ### Fast-slow 6 7 The example is a simple single-thread application similar to examples for other spies. 8 9 The code is pretty self-explanatory: `Slow.Work` should take 80% of CPU time and remaining 20% to be consumed by 10 `Fast.Work`. You may ask why `Fast` and `Slow` classes are defined in separate namespaces. The fact is that Pyroscope 11 colors frames depending on the namespaces (for .NET traces), so they are defined in this way just for sake of demo ;) 12 13 In this example, the program is built as an executable (`/dotnet/example`), therefore `-spy-name dotnetspy` argument is 14 required to tell Pyroscope how to deal with the process: 15 > CMD ["pyroscope", "exec", "-spy-name", "dotnetspy", "/dotnet/example"] 16 17 To run the example execute the following commands: 18 19 ```shell 20 # cd examples/dotnet/fast-slow 21 # docker-compose up 22 ``` 23 24 ### Web 25 26 The example is a simple ASP.NET Core web app that enables you to observe how consumed CPU time is changed by making 27 HTTP requests to [http://localhost:5000](http://localhost:5000). 28 29 In contrast to the previous example, the application is built as a dynamic library (`/dotnet/example.dll`) and 30 runs with dotnet. This allows Pyroscope to automatically detect which kind of spy to use, making `-spy-name` option 31 unnecessary: 32 > CMD ["pyroscope", "exec", "dotnet", "/dotnet/example.dll"] 33 34 To run the example execute the following commands: 35 36 ```shell 37 # cd examples/dotnet/web 38 # docker-compose up 39 ```