Hi,
I'm trying to optimise the access to the file value0 for angle sensors, or IR sensors.
Because my motion system need these data every 5ms.
ifstream is currently used, I already managed some little change to decrease access time, but it's not enough (I opened the file once at the beginning, and during the loop, I just read).
Do you know how to be faster to retrieve the value (int) inside the file ?
Maybe using POSIX like described here
https://stackoverflow.com/questions/17925051/fast-textfile-reading-in-c
What do you think ?
You seem to use a cache, but I don't understand, Are you sure that the cache is really used using this current code in ev3dev.cpp ?
// A global cache of files.
std::ifstream& ifstream_cache(const std::string &path) {
static lru_cache<std::string, std::ifstream> cache(FSTREAM_CACHE_SIZE);
static std::mutex mx;
std::lock_guard<std::mutex> lock(mx);
return cache[path];
}
BR,
Cho.
Hi,
I'm trying to optimise the access to the file value0 for angle sensors, or IR sensors.
Because my motion system need these data every 5ms.
ifstream is currently used, I already managed some little change to decrease access time, but it's not enough (I opened the file once at the beginning, and during the loop, I just read).
Do you know how to be faster to retrieve the value (int) inside the file ?
Maybe using POSIX like described here
https://stackoverflow.com/questions/17925051/fast-textfile-reading-in-c
What do you think ?
You seem to use a cache, but I don't understand, Are you sure that the cache is really used using this current code in ev3dev.cpp ?
BR,
Cho.