Skip to content

Instantly share code, notes, and snippets.

@guilledk
Created July 14, 2016 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilledk/4f44322d097c9d5fc122fd41d0e21f35 to your computer and use it in GitHub Desktop.
Save guilledk/4f44322d097c9d5fc122fd41d0e21f35 to your computer and use it in GitHub Desktop.
Prueba de rendimiento de API PyBot
list *times = lnew();
unsigned char raw[6];
struct timespec before;
struct timespec after;
for(int i = 0; i < 1000; i++){
clock_gettime(CLOCK_MONOTONIC, &before);
dev_write_to(bdevh->head->value, opcode, 1, handler);
dev_read(bdevh->head->value, raw, 6);
//printf("Distance[%d]: {%d}\n", handler, 65536 - (raw[4] + raw[5] * 256));
clock_gettime(CLOCK_MONOTONIC, &after);
long *value = malloc(sizeof(long));
*value = (after.tv_nsec - before.tv_nsec) / 1000;
ladd(times, value);
}
unsigned long sum = 0;
iter = times->head;
for(int i = 0; i < times->size; i++) {
sum += *(long*)(iter->value);
iter = iter->next;
}
printf("Average Elapsed time: %f\n", (sum / times->size)/(float)1000);
from datetime import datetime
from usb4butia import USB4Butia
rb = USB4Butia()
times = []
for x in range(1000):
dt = datetime.now()
before = dt.microsecond
rb.getDistance(6)
dt = datetime.now()
after = dt.microsecond
times.append( after - before )
print("Average elapsed time ms: ", (sum(times)/len(times))/float(1000))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment