https://github.com/tomasbouda/inlineprofiler
Lightweigth code profiling using timestamps.
https://github.com/tomasbouda/inlineprofiler
class code profiler profiling profiling-library
Last synced: 5 months ago
JSON representation
Lightweigth code profiling using timestamps.
- Host: GitHub
- URL: https://github.com/tomasbouda/inlineprofiler
- Owner: TomasBouda
- License: mit
- Created: 2018-06-20T18:33:10.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-21T07:39:14.000Z (over 7 years ago)
- Last Synced: 2025-08-01T07:42:05.749Z (6 months ago)
- Topics: class, code, profiler, profiling, profiling-library
- Language: C#
- Size: 40 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# InlineProfiler [](https://www.nuget.org/packages/TomLabs.InlineProfiler/) [](https://ci.appveyor.com/project/TomasBouda/inlineprofiler) [](https://discord.gg/jqWADRg)
Lightweigth code profiling using timestamps.
Goal of this library is to provide simple solution for first and quick profiling. You can setup few Probes and immediately see where is the bottleneck.
## Install via nuget
```ps1
Install-Package TomLabs.InlineProfiler
```
## Usage
```cs
using TomLabs.Profiling;
// Setup write output
InlineProfiler.WriteTo(x => Debug.WriteLine(x));
// And another one if you want, with custom formating
InlineProfiler.WriteTo((type, label, elapsed) => Console.WriteLine($"|{type.ToString().ToUpper()}| Label:{label} - {elapsed}ms"));
InlineProfiler.Probe("Some label");
// Some long running code
Thread.Sleep(100);
// Get current timestamp
InlineProfiler.Probe();
// Or write an absolute time spent in this section
using (InlineProfiler.ProbeSection("Slow section"))
{
// Some very long running code :)
Thread.Sleep(1000);
}
InlineProfiler.Probe();
```
Will result in this:
```
Trace>
--------
PROBE Some label: 0ms
PROBE 2: 104ms
SECTION Slow section: 1002ms
PROBE 3: 1106ms
Console>
--------
|PROBE| Label:Some label - 0ms
|PROBE| Label:2 - 104ms
|SECTION| Label:Slow section - 1002ms
|PROBE| Label:3 - 1106ms
```