Last active
September 1, 2015 07:58
-
-
Save ddemidov/e27fdf63f3ff6bb98dcf to your computer and use it in GitHub Desktop.
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 <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; | |
} |
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
#!/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)) | |
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
#!/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