[llvm-bugs] [Bug 47321] New: Simple loop with IO - LLVM much slower than GCC
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Aug 26 14:01:18 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=47321
Bug ID: 47321
Summary: Simple loop with IO - LLVM much slower than GCC
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Loop Optimizer
Assignee: unassignedbugs at nondot.org
Reporter: david.bolvansky at gmail.com
CC: llvm-bugs at lists.llvm.org
Code:
#include <string>
#include <map>
#include <fstream>
#include <iostream>
int main(int argc, char **argv) {
if (argc != 2)
return 1;
std::string dict = argv[1];
std::map<unsigned, unsigned> pwd_dist;
std::ifstream file(dict);
if (!file.is_open())
return 1;
std::string line;
while (getline(file, line)) {
unsigned pwd_len = line.length();
pwd_dist[pwd_len] += 1;
}
file.close();
for (std::map<unsigned, unsigned>::iterator it = pwd_dist.begin();
it != pwd_dist.end(); it++) {
std::cout << it->first // string (key)
<< ':' << it->second ;// string's value
if (std::next(it) != pwd_dist.end())
std::cout << ';';
}
return 0;
}
Compiled with -O3.
Clang:
0m1,219s
GCC:
0m0,623s
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200826/91547815/attachment.html>
More information about the llvm-bugs
mailing list