-
-
Notifications
You must be signed in to change notification settings - Fork 103
Open
Description
Hi, I am writing data(struct array format) in .mat file using matio(it is actually matio-cpp, cpp wrapper of matio), and I noticed that writing data in v73 requires about 5X time than in v5, is this as expected?
I am trying to give a sample code here, but the code still have some error I have not figured out. But I will put t here anyway. If I find why, I will update it.
#include <iostream>
#include <string>
#include <fstream>
#include <chrono>
#include <matiocpp/matioCpp.h>
int main(int argc, char** argv)
{
std::string sDataPath = "data.mat";
std::string sOutputV5 = "save_data_v5.mat";
std::string sOutputV73 = "save_data_v73.mat";
matioCpp::File matFile = matioCpp::File::Create(sDataPath, matioCpp::FileVersion::MAT7_3);
matioCpp::StructArray data = matFile.read("data").asStructArray();
auto startTime = std::chrono::high_resolution_clock::now();
// Read data, save as v5
matioCpp::File matFileV5 = matioCpp::File::Create(sOutputV5, matioCpp::FileVersion::MAT5);
matFileV5.write(data);
auto endV5Time = std::chrono::high_resolution_clock::now();
uint64_t v5Duration_ms = std::chrono::duration_cast<std::chrono::milliseconds>(endV5Time - startTime).count();
std::cout << "v5 writing cost " << v5Duration_ms << "ms\n";
// Read data, save as v73
matioCpp::File matFileV73 = matioCpp::File::Create(sOutputV73, matioCpp::FileVersion::MAT7_3);
matFileV73.write(data);
auto endV7Time = std::chrono::high_resolution_clock::now();
uint64_t v73Duration_ms = std::chrono::duration_cast<std::chrono::milliseconds>(endV7Time - endV5Time).count();
std::cout << "v73 writing cost " << v73Duration_ms << "ms\n";
}
data.txt
Remember rename the file to data.mat
Best,
Zheng
Metadata
Metadata
Assignees
Labels
No labels