Skip to content

Instantly share code, notes, and snippets.

@ddemidov
Last active September 1, 2015 07:58
Show Gist options
  • Save ddemidov/e27fdf63f3ff6bb98dcf to your computer and use it in GitHub Desktop.
Save ddemidov/e27fdf63f3ff6bb98dcf to your computer and use it in GitHub Desktop.
#include <iostream>
#include <chrono>
#include "ev3dev.h"
int main() {
typedef std::chrono::high_resolution_clock clock;
const int n = 1000;
ev3dev::motor m("outA");
std::cout << m.driver_name() << ", " << m.port_name() << std::endl;
long sum = 0;
auto tic = clock::now();
for(int i = 0; i < n; ++i) sum += m.position();
auto toc = clock::now();
std::cout
<< n << " readings in "
<< std::chrono::duration_cast<std::chrono::microseconds>(toc - tic).count()
<< " us" << std::endl;
}
#!/usr/bin/python
from time import time
from ev3dev import *
m = motor('outA')
print("%s, %s" % (m.driver_name, m.port_name))
n = 1000
sum = 0
tic = time()
for i in xrange(n): sum += m.position
toc = time()
print("%d readings in %f seconds" % (n, toc - tic))
#!/usr/bin/python
from time import time
from ev3dev_pp import * # ev3dev_pp is pure python ev3dev bindings
m = Motor('outA')
print("%s, %s" % (m.driver_name, m.port_name))
n = 1000
sum = 0
tic = time()
for i in xrange(n): sum += m.position
toc = time()
print("%d readings in %f seconds" % (n, toc - tic))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment