I'm trying to exclude the conversion of string into an object in a function. This is the involved function:
std::vector<std::pair<value_type, size_t>> read_file(const std::string path, benchmark::State& state) {
std::string kmer;
std::vector<std::pair<value_type, size_t>> data;
std::ifstream file(path);
while (std::getline(file, kmer)) {
state.PauseTiming();
kmer_t tmp(kmer);
state.ResumeTiming();
data.push_back(std::make_pair(tmp.value, tmp.index));
}
return data;
}
The function scope is to read a file and convert line by line into an object. The resulted object is insered into a vector of pair.
I include in my project the google benchmark
library to compute how much time and memory is used. I would like to exclude the conversion from the total count. I implemented the function just like the documentation said but the resulting time is much higher then a normal computation without the timer management.
I also found this old but related opened issue but I can't resolve my problem. How can I fix this problem or there are any work around for the issue?