<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - The performance of vector::assign is 100 times worse than that of libstdc++."
href="https://bugs.llvm.org/show_bug.cgi?id=48893">48893</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>The performance of vector::assign is 100 times worse than that of libstdc++.
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>8.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>release blocker
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>2077213809@qq.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=24423" name="attach_24423" title="the testcase">attachment 24423</a> <a href="attachment.cgi?id=24423&action=edit" title="the testcase">[details]</a></span>
the testcase
For details about test cases, see the attachment.
./gccO0.out
copy 1610957372.518706
copy1 1610957372.526591
7885
./clangO0.out
copy 1610957377.298682
copy1 1610957378.455563
1156881
./gccO2.out
copy 1610957396.558745
copy1 1610957396.566606
7861
./clangO2.out
copy 1610957407.81578
copy1 1610957407.179067
97489
the test function
int main(int argc, char* argv[])
{
std::vector<uint8_t> data;
data.resize(1024UL*1024*24);
std::vector<uint8_t> data1;
struct timeval tv,tv1;
gettimeofday(&tv, NULL);
data1.assign(data.begin(), data.end());
gettimeofday(&tv1, NULL);
std::cout << "copy " << tv.tv_sec <<"." << tv.tv_usec << std::endl;
std::cout << "copy1 " << tv1.tv_sec <<"." << tv1.tv_usec << std::endl;
std::cout << tv1.tv_sec * 1000000 + tv1.tv_usec - (tv.tv_sec*1000000 +
tv.tv_usec) << std::endl;
return 0;
}
The main function consumed is __construct_range_forward. libcxx use the
__construct_range_forward
Each element is constructed using the construct method, which is constructed
using the placement new method. GCC uses std::uninitialized_copy to copy the
memory. The performance is significantly better than that of libcxx.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>