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

Switch Windows z_clock to QueryPerformanceCounter #310

Merged
merged 4 commits into from
Jan 8, 2024

Conversation

jean-roland
Copy link
Contributor

As stated in #272, the Windows z_clock implementation was the same as z_time which wasn't ideal.

This PR aligns z_clock with the Rust clock implementation that uses Windows' QueryPerformanceCounter.

As a bonus, it switches the scout timeout loop to z_clock instead of z_time which is more suited.

return now;
}

unsigned long z_clock_elapsed_us(z_clock_t *instant) { return z_clock_elapsed_ms(instant) * 1000; }
unsigned long z_clock_elapsed_us(z_clock_t *instant) {

Check warning

Code scanning / Cppcheck (reported by Codacy)

misra violation 804 with no text in the supplied rule-texts-file Warning

misra violation 804 with no text in the supplied rule-texts-file
return now;
}

unsigned long z_clock_elapsed_us(z_clock_t *instant) { return z_clock_elapsed_ms(instant) * 1000; }
unsigned long z_clock_elapsed_us(z_clock_t *instant) {

Check warning

Code scanning / Cppcheck (reported by Codacy)

Parameter 'instant' can be declared as pointer to const Warning

Parameter 'instant' can be declared as pointer to const

// Hardware not supporting QueryPerformanceFrequency
if (frequency.QuadPart == 0) {
return 0;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.5 rule Note

MISRA 15.5 rule
return elapsed;
// Hardware not supporting QueryPerformanceFrequency
if (frequency.QuadPart == 0) {
return 0;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.5 rule Note

MISRA 15.5 rule
return elapsed;
// Hardware not supporting QueryPerformanceFrequency
if (frequency.QuadPart == 0) {
return 0;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.5 rule Note

MISRA 15.5 rule
@@ -113,7 +113,7 @@ int main(int argc, char** argv) {
results[i] = z_clock_elapsed_us(&measure_start);
}
for (unsigned int i = 0; i < args.number_of_pings; i++) {
printf("%d bytes: seq=%d rtt=%luµs, lat=%luµs\n", args.size, i, results[i], results[i] / 2);
printf("%d bytes: seq=%d rtt=%luus, lat=%luus\n", args.size, i, results[i], results[i] / 2);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Windows shell is really bad at parsing anything else than ASCII

@@ -55,8 +55,8 @@ _z_hello_list_t *__z_scout_loop(const _z_wbuf_t *wbf, const char *locator, unsig
// The receiving buffer
_z_zbuf_t zbf = _z_zbuf_make(Z_BATCH_UNICAST_SIZE);

z_time_t start = z_time_now();
while (z_time_elapsed_ms(&start) < period) {
z_clock_t start = z_clock_now();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

z_clock_t is more adapted than z_time_t to a timeout implementation like here

@Mallets Mallets merged commit 76a5b4f into eclipse-zenoh:master Jan 8, 2024
47 checks passed
@jean-roland jean-roland deleted the ft_windows_qpc branch January 8, 2024 13:45
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.

2 participants