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

Use high resolution time for Timer::read(). #7975

Merged
merged 1 commit into from
Oct 1, 2018
Merged

Use high resolution time for Timer::read(). #7975

merged 1 commit into from
Oct 1, 2018

Conversation

tkem
Copy link
Contributor

@tkem tkem commented Sep 3, 2018

Description

float Timer::read() delegates to Timer::read_us(), which returns an int, i.e. a signed 32-bit value capable of storing values up to 2147483647 us (the use of signed types in this interface has always bothered me, but that's outside the scope of this PR). Therefore, Timer::read() will return values up to ~2147.5f seconds, or 35.8 minutes, even though the float return type could represent a much higher range (3.402823e+38 seconds, at reduced precision, of course).

By contrast, int Timer::read_ms() returns read_high_resolution_us() / 1000, so the maximum (signed) value is 2147483647 ms, or more than 24 days (if I haven't made a mistake).

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Breaking change

Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the float return here, but if we have it, this is clearly a better implementation.

@cmonr
Copy link
Contributor

cmonr commented Sep 27, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Sep 27, 2018

Build : SUCCESS

Build number : 3177
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7975/

Triggering tests

/morph test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Sep 27, 2018

@cmonr
Copy link
Contributor

cmonr commented Sep 27, 2018

/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Sep 27, 2018

@0xc0170 0xc0170 merged commit 9b0e534 into ARMmbed:master Oct 1, 2018
@tkem tkem deleted the fix/timer-read-range branch October 3, 2018 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants