Right now, I'm doing it like this:
//encoding
std::vector<float> data = ...
const unsigned char* bytes = reinterpret_cast<const unsigned char*>(&data[0]);
std::vector<unsigned char> byteVec(bytes, bytes + sizeof(float) * data.size());
std::string newData = base64_encode(&byteVec[0], byteVec.size());
//decoding
std::vector<unsigned char> decodedData = base64_decode(newData);
unsigned char* bytes = &(decodedData[0]); // point to beginning of memory
float* floatArray = reinterpret_cast<float*>(bytes);
std::vector<float> floatVec(floatArray, floatArray + decodedData.size() / sizeof(float));
The encoding takes 0.04 seconds, and the decoding takes 0.08 seconds. This is WAY too long. Is there a faster method?
I'm using a base64 library I found online, but if there is a faster method by using hex instead, I am definitely open to that!
The functions I use are the ones found in this answer.
EDIT: I also couldn't find a way to convert to/from hex for this vector, so any solutions for that would be very appreciated.
EDIT: All the time is in the encode/decode functions. None of it is the conversion of vectors/arrays or bytes/floats.