I am benchmarking linux and C++ program to compare the results. I am testing wc -l command and C++ program doing the same but linux command wc -l is much faster than c++ progarm. Why?
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char* argv[])
{
ifstream in(argv[1]);
char line[1000];
int count =0;
while(in)
{
in.getline(line ,1000);
count++;
}
in.close();
cout << count <<endl;
return 0;
}
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char* argv[])
{
ifstream in(argv[1]);
char line[1000];
int count =0;
while(in)
{
in.getline(line ,1000);
count++;
}
in.close();
cout << count <<endl;
return 0;
}
Comment