tests/ztimer_overhead: update to use signed ztimer_overhead()
This commit is contained in:
parent
b45f4236de
commit
90ca4f3b42
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "ztimer.h"
|
#include "ztimer.h"
|
||||||
@ -32,16 +33,17 @@ int main(void)
|
|||||||
{
|
{
|
||||||
uint32_t total = 0;
|
uint32_t total = 0;
|
||||||
|
|
||||||
uint16_t min = 0xFFFF;
|
int32_t min = INT32_MAX;
|
||||||
uint16_t max = 0;
|
int32_t max = INT32_MIN;
|
||||||
|
|
||||||
/* unset configured adjustment */
|
/* unset configured adjustment */
|
||||||
/* ZTIMER_USEC->adjust = 0; */
|
/* ZTIMER_USEC->adjust = 0; */
|
||||||
|
printf("ZTIMER_USEC->adjust = %" PRIu32 "\n", ZTIMER_USEC->adjust);
|
||||||
|
|
||||||
unsigned n = SAMPLES;
|
unsigned n = SAMPLES;
|
||||||
while (n--) {
|
while (n--) {
|
||||||
unsigned overhead = ztimer_overhead(ZTIMER_USEC, BASE);
|
int32_t overhead = ztimer_overhead(ZTIMER_USEC, BASE);
|
||||||
total += overhead;
|
total += labs(overhead);
|
||||||
if (overhead < min) {
|
if (overhead < min) {
|
||||||
min = overhead;
|
min = overhead;
|
||||||
}
|
}
|
||||||
@ -50,7 +52,8 @@ int main(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("min=%u max=%u avg=%" PRIu32 "\n", min, max, (total / SAMPLES));
|
printf("min=%" PRIi32 " max=%" PRIi32 " avg_diff=%" PRIi32 "\n", min, max,
|
||||||
|
(total / SAMPLES));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ from testrunner import run
|
|||||||
|
|
||||||
|
|
||||||
def testfunc(child):
|
def testfunc(child):
|
||||||
child.expect(r"min=\d+ max=\d+ avg=\d+\r\n")
|
child.expect(r"min=-?\d+ max=-?\d+ avg_diff=\d+\r\n")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user