This is a prerelease version of HighPrecisionTimeStamps.
There is a newer version of this package available.
See the version list below for details.
dotnet add package HighPrecisionTimeStamps --version
NuGet\Install-Package HighPrecisionTimeStamps -Version
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="HighPrecisionTimeStamps" Version="" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HighPrecisionTimeStamps --version
#r "nuget: HighPrecisionTimeStamps,"
#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 HighPrecisionTimeStamps as a Cake Addin
#addin nuget:?package=HighPrecisionTimeStamps&version=

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

High Precision Timestamps

A timestamp utility used by my other projects superior for my use-cases to use of DateTime.Now.

This project provides high precision timestamps (calibrated on a per-thread basis and periodically synchronized with system clock) that is very useful for obtaining DateTimes which when subtracted from other DateTimes obtained on the same thread within the same period provides a useful delta. The source is the stopwatch, which uses a high performance event counter, if available. Also, rather than just using the tick count, it allows the timestamp to serve as a readable and relatable timestamp in event logs. It should not be used for timestamps that users rely-on to have a high degree of accuracy vis-a-vis local time, but, in most cases, can be quite accurate. When considering two such DateTimes obtained within a (short) calibration period of each other on the same thread, the elapsed difference between themselves should be as accurate as the machine's high precision event timer.

Another utility herein is the monotonic timestamp. This also uses Stopwatch ticks but is calibrated once at startup for all threads. A monotonic clock never goes backwards, unlike a system clock (subject to user adjustment, daylight savings time, synchronization with a time server, leap seconds etc). These stamps store an offset in stopwatch ticks from the reference time (readonly static value computed first time stamp provider is activated). Thus, these stamps can be understood to be monotonic ticks elapsed since a reference time. They can also be converted into date time for storage as timestamps but, since calibrated once only, drift between the monotonic clock and system clock (in addition to changes to system clock) may make their timestamps misleading over time. These values cannot be serialized as-is (because they rely on static readonly in-process state to derive their semantic meaning). They can be converted to DateTimes but be wary of the issues I have described. At a future time I may provide an "archive" format for these to allow them to be saved or serialized. Understood as monotonic ticks since a reference datetime, these are superior to the high precision stamps. Also, the value contains only a long (the calibration data, again, is static) so recording the stamp and comparisons / arithmetic is quick. String conversions, extracting date times may be slower but it is more important to record and compare quickly than to log, print, output quickly for my use cases.

This project is currently used by me in other projects where it has proved useful for the particular ways it is employed in those projects. Extensive pan-use case testing has not been performed. There is a basic console test application on the source page for this project on GitHub. Eventually I may test this more extensively and document it more rigorously but that is not high on my priority list right now: it works well for what I use it for. If you would like to help get this into "general use library shape", contact me.

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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  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 tizen40 was computed.  tizen60 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 (1)

Showing the top 1 NuGet packages that depend on HighPrecisionTimeStamps:

Package Downloads

Synchronization Library and Static Analysis Tool for C# 8 DotNetVault is a library and static code analysis tool that makes managing shared mutable state in multi-threaded applications more manageable and less error prone. It also provides a common abstraction over several commonly used synchronization mechanisms, allowing you to change from one underlying type to another (such as from lock free synchronization to mutex/monitor lock based) without needing to refactor your code. Where errors do still occur, they are easier to locate and identify. The project description (a detailed design document) can be read here: https://github.com/cpsusie/DotNetVault/blob/master/DotNetVault_Description_v1.0.pdf. A quick start guide for installation (Windows, Vs 2019+) can be found here: https://github.com/cpsusie/DotNetVault/blob/v0.2.5.x/QuickStart_Install_VS2019_Windows.md. A quick start guide for installation (Tested on Amazon Linux, Rider 2019.3.1+) can be found here: https://github.com/cpsusie/DotNetVault/blob/v0.2.5.x/Quick_Start_Install_Rider_Amazon_Linux.md. A guided tour / quick start guide for this project's functionality can be found here: https://github.com/cpsusie/DotNetVault/blob/v0.2.5.x/Quick_Start_Functionality_Tour.md

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated 235 2/1/2022 26,865 10/1/2021 366 9/19/2021 371 9/4/2021 462 8/21/2021
1.0.0 444 8/13/2021
0.1.1-beta 325 8/5/2021
0.1.0 505 12/13/2020 307 12/6/2020 291 11/27/2020
0.0.4-beta 304 11/18/2020
0.0.3-beta 360 11/15/2020
0.0.2-alpha 281 11/14/2020
0.0.1-alpha 386 1/25/2020

This release fixes a misspelled namespace: HpTimesStamps -> HpTimeStamps.  This is a breaking change and client code must refactor.  Hopefully, there will not be any more breaking changes that require code refactors.
     It also adds a unit test project that focuses on conversions.  More tests will be forthcoming.
     SourceLink support will be attempted.   It may not work correctly on this release but it is a goal.
     Also, a dependency to System.Memory Nuget package has been added.  I hope to get rid of dynamic array allocations in the Int128 multiplication, division and modulus operations.