Method | Mean | Error | StdDev |
---|---|---|---|
DateTimeNowTicks | 87.08 ns | 1.0897 ns | 1.0193 ns |
DateTimeUtcNowTicks | 68.06 ns | 0.5209 ns | 0.4617 ns |
DateTimeOffsetNowTicks | 114.62 ns | 0.8232 ns | 0.6874 ns |
DateTimeOffsetUtcNowTicks | 87.15 ns | 0.2953 ns | 0.2617 ns |
Last active
August 23, 2019 02:04
-
-
Save ufcpp/07f05e81f29935c09bfc7270bb37b678 to your computer and use it in GitHub Desktop.
やっぱ UtcNow の方が速いんだ。的なやつ。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Running; | |
using System; | |
public class TimeBenchmark | |
{ | |
[Benchmark] | |
public long DateTimeNowTicks() => DateTime.Now.Ticks; | |
[Benchmark] | |
public long DateTimeUtcNowTicks() => DateTime.UtcNow.Ticks; | |
[Benchmark] | |
public long DateTimeOffsetNowTicks() => DateTimeOffset.Now.Ticks; | |
[Benchmark] | |
public long DateTimeOffsetUtcNowTicks() => DateTimeOffset.UtcNow.Ticks; | |
} | |
class Program | |
{ | |
static void Main() | |
{ | |
BenchmarkRunner.Run<TimeBenchmark>(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment