Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTime Improvements #58

Merged
merged 7 commits into from
Mar 3, 2021
Merged

DateTime Improvements #58

merged 7 commits into from
Mar 3, 2021

Conversation

Turnerj
Copy link
Member

@Turnerj Turnerj commented May 18, 2020

Multiple different things here for improving performance around the current time access. This is based on the details discussed in this Tweet: https://twitter.com/Nick_Craver/status/1262045129038344192

Currently it is ~22% faster in benchmarking.

Method Iterations Mean Error StdDev Median Ratio RatioSD Gen 0 Gen 1 Gen 2 Allocated
CacheTower_MemoryCacheLayer_Direct 1 645.5 ns 3.38 ns 2.64 ns 645.7 ns 0.31 0.00 0.3052 - - 960 B
LazyCache_MemoryProvider 1 1,897.5 ns 36.76 ns 42.33 ns 1,878.0 ns 0.91 0.02 0.4139 - - 1304 B
CacheTower_MemoryCacheLayer_ViaCacheStack 1 2,088.9 ns 14.01 ns 12.42 ns 2,089.6 ns 1.00 0.00 0.4730 - - 1488 B
LazyCache_MemoryProviderAsync 1 2,111.1 ns 15.39 ns 14.40 ns 2,111.7 ns 1.01 0.01 0.4845 - - 1520 B
EasyCaching_InMemory 1 9,868.3 ns 67.82 ns 63.44 ns 9,853.6 ns 4.72 0.04 1.3580 - - 4289 B
CacheManager_MicrosoftMemoryCache 1 19,312.1 ns 121.42 ns 113.57 ns 19,252.9 ns 9.25 0.07 2.4719 1.2207 - 7848 B
EasyCaching_InMemoryAsync 1 21,870.8 ns 392.46 ns 347.91 ns 21,848.8 ns 10.47 0.17 2.0142 - - 6264 B
CacheTower_MemoryCacheLayer_Direct 1000 202,790.5 ns 1,979.25 ns 1,851.39 ns 202,984.7 ns 0.33 0.00 10.4980 - - 32929 B
CacheTower_MemoryCacheLayer_ViaCacheStack 1000 614,702.3 ns 6,001.12 ns 5,011.21 ns 616,239.8 ns 1.00 0.00 9.7656 - - 33458 B
LazyCache_MemoryProvider 1000 1,804,438.1 ns 24,963.15 ns 60,763.76 ns 1,783,246.7 ns 3.08 0.16 335.9375 - - 1064240 B
CacheManager_MicrosoftMemoryCache 1000 1,940,035.3 ns 11,546.63 ns 10,800.72 ns 1,940,122.3 ns 3.16 0.03 87.8906 - - 279719 B
LazyCache_MemoryProviderAsync 1000 1,988,760.9 ns 14,423.38 ns 12,044.17 ns 1,994,035.9 ns 3.24 0.04 406.2500 - - 1280245 B
EasyCaching_InMemory 1000 4,516,944.6 ns 45,462.25 ns 40,301.10 ns 4,522,247.3 ns 7.36 0.10 343.7500 - - 1099413 B
EasyCaching_InMemoryAsync 1000 7,387,677.6 ns 99,594.49 ns 93,160.74 ns 7,371,528.9 ns 11.99 0.18 664.0625 - - 2068658 B
CacheTower_MemoryCacheLayer_Direct 1000000 203,166,917.9 ns 1,194,781.30 ns 997,696.50 ns 203,064,033.3 ns 0.33 0.00 10000.0000 - - 32000928 B
CacheTower_MemoryCacheLayer_ViaCacheStack 1000000 614,075,766.7 ns 8,648,199.02 ns 8,089,530.72 ns 613,836,100.0 ns 1.00 0.00 10000.0000 - - 32002320 B
LazyCache_MemoryProvider 1000000 1,757,410,420.0 ns 12,920,524.91 ns 12,085,867.02 ns 1,758,450,100.0 ns 2.86 0.04 339000.0000 - - 1064000240 B
CacheManager_MicrosoftMemoryCache 1000000 1,888,174,873.3 ns 18,181,070.11 ns 17,006,584.27 ns 1,893,119,100.0 ns 3.08 0.05 86000.0000 - - 272009128 B
LazyCache_MemoryProviderAsync 1000000 1,977,939,364.3 ns 11,243,719.15 ns 9,967,264.16 ns 1,980,478,550.0 ns 3.22 0.04 408000.0000 - - 1280000344 B
EasyCaching_InMemory 1000000 4,571,407,828.6 ns 41,049,432.55 ns 36,389,252.74 ns 4,577,811,250.0 ns 7.44 0.12 349000.0000 - - 1096213192 B
EasyCaching_InMemoryAsync 1000000 7,430,601,366.7 ns 46,383,876.25 ns 43,387,506.62 ns 7,423,960,300.0 ns 12.10 0.19 663000.0000 - - 2064400712 B

@Turnerj Turnerj force-pushed the datetime-improvements branch from eb0b94b to 0e5605b Compare January 24, 2021 06:45
Approximately 22% faster in benchmarking
@Turnerj Turnerj force-pushed the datetime-improvements branch from 0e5605b to 473c624 Compare March 3, 2021 01:12
Turnerj added 6 commits March 3, 2021 11:49
Also introduced documentation to explain the logic a bit better.
The new DateTimeProvider updates the time every second with its timer. The unit test however performs a check within that second so an update to the current "time" is required.
This helps avoid race conditions against the timer, leading to the minimum DateTime value being returned.
@Turnerj Turnerj merged commit 0a5ac80 into master Mar 3, 2021
@Turnerj Turnerj deleted the datetime-improvements branch March 3, 2021 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant