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

Improve TimeSpan precision #26992

Merged
merged 1 commit into from Oct 2, 2019

Conversation

@idlerboris
Copy link
Contributor

commented Oct 2, 2019

Fixes dotnet/corefx#41380

Related corefx PR dotnet/coreclr#41499

Change multiplying by (x * (1.0 / BigValue)) on (x / BigValue).

Change multiplying by (x * (1.0 / BigValue)) on (x / BigValue).

Fix #41380
@dnfclas

This comment has been minimized.

Copy link

commented Oct 2, 2019

CLA assistant check
All CLA requirements met.


public double TotalSeconds => (double)_ticks * SecondsPerTick;
public double TotalSeconds => (double)_ticks / TicksPerSecond;

This comment has been minimized.

Copy link
@EgorBo

EgorBo Oct 2, 2019

Contributor

while it improves precision it also makes it slower,
here is the difference between mulss and divss for my macbook's haswell:

vdivss (Latency: 10-20,  R.Throughput: 7-14)
vmulss (Latency:     5,  R.Throughput:  0.5)

This comment has been minimized.

Copy link
@tannergooding

tannergooding Oct 2, 2019

Member

I think ensuring we return an accurate TotalSeconds count is generally more important than worrying about a couple of cycles of throughput difference.

If users really have a hot path here and find the loss of precision is acceptable, it is possible for them to do the faster code themselves :) (just get TimeSpan.Ticks * (1.0 / TimeSpan.TicksPerSecond))

@Anipik Anipik requested review from tannergooding and adamsitnik Oct 2, 2019
@jkotas
jkotas approved these changes Oct 2, 2019
@jkotas jkotas merged commit 1908883 into dotnet:master Oct 2, 2019
51 of 53 checks passed
51 of 53 checks passed
coreclr-ci Build #20191002.11 failed
Details
coreclr-ci (Run Test Pri0 R2R OSX x64 checked) Run Test Pri0 R2R OSX x64 checked failed
Details
WIP Ready for review
Details
coreclr-ci (Build Linux arm checked) Build Linux arm checked succeeded
Details
coreclr-ci (Build Linux arm64 checked) Build Linux arm64 checked succeeded
Details
coreclr-ci (Build Linux arm64 release) Build Linux arm64 release succeeded
Details
coreclr-ci (Build Linux x64 checked) Build Linux x64 checked succeeded
Details
coreclr-ci (Build Linux_musl x64 checked) Build Linux_musl x64 checked succeeded
Details
coreclr-ci (Build Linux_musl x64 release) Build Linux_musl x64 release succeeded
Details
coreclr-ci (Build Linux_rhel6 x64 release) Build Linux_rhel6 x64 release succeeded
Details
coreclr-ci (Build OSX x64 checked) Build OSX x64 checked succeeded
Details
coreclr-ci (Build Test Pri0 CoreFX Linux x64 checked) Build Test Pri0 CoreFX Linux x64 checked succeeded
Details
coreclr-ci (Build Test Pri0 CoreFX Windows_NT x64 checked) Build Test Pri0 CoreFX Windows_NT x64 checked succeeded
Details
coreclr-ci (Build Test Pri0 Linux arm checked) Build Test Pri0 Linux arm checked succeeded
Details
coreclr-ci (Build Test Pri0 Linux arm64 checked) Build Test Pri0 Linux arm64 checked succeeded
Details
coreclr-ci (Build Test Pri0 Linux_musl x64 release) Build Test Pri0 Linux_musl x64 release succeeded
Details
coreclr-ci (Build Test Pri0 OSX x64 checked) Build Test Pri0 OSX x64 checked succeeded
Details
coreclr-ci (Build Test Pri0 R2R OSX x64 checked) Build Test Pri0 R2R OSX x64 checked succeeded
Details
coreclr-ci (Build Test Pri0 R2R Windows_NT x64 checked) Build Test Pri0 R2R Windows_NT x64 checked succeeded
Details
coreclr-ci (Build Test Pri0 R2R Windows_NT x86 checked) Build Test Pri0 R2R Windows_NT x86 checked succeeded
Details
coreclr-ci (Build Test Pri0 Windows_NT arm checked) Build Test Pri0 Windows_NT arm checked succeeded
Details
coreclr-ci (Build Test Pri0 Windows_NT arm64 checked) Build Test Pri0 Windows_NT arm64 checked succeeded
Details
coreclr-ci (Build Test Pri0 Windows_NT x64 checked) Build Test Pri0 Windows_NT x64 checked succeeded
Details
coreclr-ci (Build Test Pri0 Windows_NT x86 checked) Build Test Pri0 Windows_NT x86 checked succeeded
Details
coreclr-ci (Build Windows_NT arm checked) Build Windows_NT arm checked succeeded
Details
coreclr-ci (Build Windows_NT arm release) Build Windows_NT arm release succeeded
Details
coreclr-ci (Build Windows_NT arm64 checked) Build Windows_NT arm64 checked succeeded
Details
coreclr-ci (Build Windows_NT arm64 release) Build Windows_NT arm64 release succeeded
Details
coreclr-ci (Build Windows_NT x64 checked) Build Windows_NT x64 checked succeeded
Details
coreclr-ci (Build Windows_NT x64 debug) Build Windows_NT x64 debug succeeded
Details
coreclr-ci (Build Windows_NT x64 release) Build Windows_NT x64 release succeeded
Details
coreclr-ci (Build Windows_NT x86 checked) Build Windows_NT x86 checked succeeded
Details
coreclr-ci (Build Windows_NT x86 debug) Build Windows_NT x86 debug succeeded
Details
coreclr-ci (Checkout (Unix)) Checkout (Unix) succeeded
Details
coreclr-ci (Checkout (Windows)) Checkout (Windows) succeeded
Details
coreclr-ci (Formatting Linux x64) Formatting Linux x64 succeeded
Details
coreclr-ci (Run Test Pri0 CoreFX Linux x64 checked) Run Test Pri0 CoreFX Linux x64 checked succeeded
Details
coreclr-ci (Run Test Pri0 CoreFX Windows_NT x64 checked) Run Test Pri0 CoreFX Windows_NT x64 checked succeeded
Details
coreclr-ci (Run Test Pri0 Linux arm checked) Run Test Pri0 Linux arm checked succeeded
Details
coreclr-ci (Run Test Pri0 Linux arm64 checked) Run Test Pri0 Linux arm64 checked succeeded
Details
coreclr-ci (Run Test Pri0 Linux x64 checked) Run Test Pri0 Linux x64 checked succeeded
Details
coreclr-ci (Run Test Pri0 Linux_musl x64 checked) Run Test Pri0 Linux_musl x64 checked succeeded
Details
coreclr-ci (Run Test Pri0 Linux_musl x64 release) Run Test Pri0 Linux_musl x64 release succeeded
Details
coreclr-ci (Run Test Pri0 OSX x64 checked) Run Test Pri0 OSX x64 checked succeeded
Details
coreclr-ci (Run Test Pri0 R2R Linux x64 checked) Run Test Pri0 R2R Linux x64 checked succeeded
Details
coreclr-ci (Run Test Pri0 R2R Windows_NT x64 checked) Run Test Pri0 R2R Windows_NT x64 checked succeeded
Details
coreclr-ci (Run Test Pri0 R2R Windows_NT x86 checked) Run Test Pri0 R2R Windows_NT x86 checked succeeded
Details
coreclr-ci (Run Test Pri0 Windows_NT arm checked) Run Test Pri0 Windows_NT arm checked succeeded
Details
coreclr-ci (Run Test Pri0 Windows_NT arm64 checked) Run Test Pri0 Windows_NT arm64 checked succeeded
Details
coreclr-ci (Run Test Pri0 Windows_NT x64 checked) Run Test Pri0 Windows_NT x64 checked succeeded
Details
coreclr-ci (Run Test Pri0 Windows_NT x86 checked) Run Test Pri0 Windows_NT x86 checked succeeded
Details
coreclr-ci (Test crossgen-comparison Linux arm checked) Test crossgen-comparison Linux arm checked succeeded
Details
license/cla All CLA requirements met.
Details
@jkotas

This comment has been minimized.

Copy link
Member

commented Oct 2, 2019

@idlerboris Thank you!

jkotas added a commit to jkotas/coreclr that referenced this pull request Oct 3, 2019
Change multiplying by (x * (1.0 / BigValue)) on (x / BigValue).

Fix #41380
jkotas added a commit that referenced this pull request Oct 4, 2019
Change multiplying by (x * (1.0 / BigValue)) on (x / BigValue).

Fix #41380
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corefx that referenced this pull request Oct 4, 2019
Change multiplying by (x * (1.0 / BigValue)) on (x / BigValue).

Fix dotnet#41380

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corert that referenced this pull request Oct 4, 2019
Change multiplying by (x * (1.0 / BigValue)) on (x / BigValue).

Fix #41380

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/mono that referenced this pull request Oct 4, 2019
Change multiplying by (x * (1.0 / BigValue)) on (x / BigValue).

Fix #41380

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
stephentoub added a commit to dotnet/corefx that referenced this pull request Oct 4, 2019
Change multiplying by (x * (1.0 / BigValue)) on (x / BigValue).

Fix #41380

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
jkotas added a commit to dotnet/corert that referenced this pull request Oct 5, 2019
Change multiplying by (x * (1.0 / BigValue)) on (x / BigValue).

Fix #41380

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
marek-safar added a commit to mono/mono that referenced this pull request Oct 5, 2019
Change multiplying by (x * (1.0 / BigValue)) on (x / BigValue).

Fix #41380

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.