codetimer 0.0.37

There is a newer version of this package available.
See the version list below for details.
dotnet add package codetimer --version 0.0.37
NuGet\Install-Package codetimer -Version 0.0.37
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="codetimer" Version="0.0.37" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add codetimer --version 0.0.37
#r "nuget: codetimer, 0.0.37"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install codetimer as a Cake Addin
#addin nuget:?package=codetimer&version=0.0.37

// Install codetimer as a Cake Tool
#tool nuget:?package=codetimer&version=0.0.37

code-timer

CodeTimer provides a standardized way to time the end-to-end cost, and the contribution of individual code segments within a method.

Build status nuget

Installation

Nuget
Install-Package codetimer

dotnet CLI
dotnet add package codetimer

Example

Creates a new CodeTimer, passing in a logger and specifying the expected ceiling time for the timing operation.

var codeTimer = new CodeTimer.CodeTimer("GetDetailsView", localLogger)
     {
         ExpectedMilliseconds = 1200
     };

Usage example

Call Mark() after to measure the performance cost of individual blocks to help identify which parts of a method are the most expensive.

public List<Blah> DoSomething() {

    var timer = new CodeTimer("DoSomething", localLogger)
    {
        ExpectedMilliseconds = 1200
    };

    var data = MakeDatabaseCall();
    timer.Mark("Get initial data");

    myWebService.CallSomething(data.Id);
    timer.Mark("Updated backend service");

    var coll = new List<Blah>();
    foreach(var foo in data.Bars) {
        coll.Add(foo.Blah);
    }
    timer.Mark("Created list of Blah's");

    // Stops the timer and logs the result 
    // Logs as Error if (Success == false)
    timer.Complete(); 

    return coll;
}

Formatting Example

The CodeTimer has a pluggable formatter for returning results and which is used to write to Logs if an ILogger is passed in to the constructor.

The example below displays an example result which is returned by the default Formatter.

var codeTimer = new CodeTimer("Case1", localLogger)
{
    ExpectedMilliseconds = 1200
};

// Do something
codeTimer.Mark("Start");  // 400ms

// Do another thing
codeTimer.Mark("Middle"); // 800ms

// Do last thing
codeTimer.Mark("End"); // 1200ms
codeTimer.Complete(); // 1201ms

Console.WriteLine(codeTimer.GetFormattedResult())

// Displays
Case1 timer failed.  Ran for 1201ms.  Expected 1000ms
 - Start: 400ms
 - Middle: 800ms
 - End: 1200ms

Meta

Darren Neimke – @digory

Distributed under the MIT license. See LICENSE for more information.

https://github.com/dneimke/code-timer/blob/master/LICENSE

Contributing

  1. Fork it (https://github.com/yourname/yourproject/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.1 is compatible.  netstandard1.2 was computed.  netstandard1.3 was computed.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 was computed.  netstandard2.1 was computed. 
.NET Framework net45 was computed.  net451 was computed.  net452 is compatible.  net46 was computed.  net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Windows Phone wpa81 was computed. 
Windows Store netcore was computed.  netcore45 was computed.  netcore451 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.48 941 9/17/2018
0.0.47 771 9/17/2018
0.0.45 2,274 10/30/2017
0.0.44 866 10/30/2017
0.0.43 865 10/28/2017
0.0.41 904 10/27/2017
0.0.40 893 10/24/2017
0.0.39 870 10/24/2017
0.0.38 905 10/24/2017
0.0.37 984 10/23/2017
0.0.36 884 10/23/2017
0.0.34 882 10/23/2017
0.0.33 867 10/23/2017
0.0.16 872 10/22/2017
0.0.14 859 10/21/2017
0.0.12 987 10/20/2017