Linux benchmark for CI20-os demonstration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/time.h> | |
#include <inttypes.h> | |
#include <stdio.h> | |
uint32_t ms(struct timeval *from, struct timeval *to) | |
{ | |
uint32_t from_ms, to_ms; | |
from_ms = (from->tv_sec * 1000) + (from->tv_usec / 1000); | |
to_ms = (to->tv_sec * 1000) + (to->tv_usec / 1000); | |
return to_ms - from_ms; | |
} | |
int main(int argc, char **argv) | |
{ | |
int run; | |
struct timeval prev, cur; | |
for(run = 0; run < 3; run ++) { | |
volatile uint32_t i; | |
gettimeofday(&prev, 0); | |
for(i = 0; i < 0xfffffff; i++) | |
; | |
gettimeofday(&cur, 0); | |
printf("%04x\n", ms(&prev, &cur)); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment