Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Везде, где есть место копированию может происходить и перемещение
- #include <iostream>
- #include <map>
- #include <set>
- #include <string>
- #include <vector>
- using namespace std;
- string MakeString()
- {
- return string(100000000,'a');
- }
- vector<int> MakeVector()
- {
- return vector<int>(100000000, 0);
- }
- int main()
- {
- {
- LOG_DURATION("assignment, with variable");
- string target_string = "old value";
- string source_string = MakeString();
- target_string = source_string;
- }
- {
- LOG_DURATION("assignment, without variable");
- string target_string = "old value";
- target_string = MakeString();
- }
- {
- LOG_DURATION("set::insert, with variable");
- set<string> strings;
- string heavy_string = MakeString();
- strings.insert(heavy_string);
- }
- {
- LOG_DURATION("set::insert, without variable");
- set<vector<int>> vectors;
- strings.insert(MakeString());
- }
- {
- LOG_DURATION("set::insert for vector, with variable");
- set<vector<int>> vectors;
- vector<int> heavy_vector = MakeVector();
- vectors.insert(heavy_vector);
- }
- {
- LOG_DURATION("set::insert for vector, without variable");
- set<vector<int>> vectors;
- vectors.insert(MakeVector());
- }
- {
- LOG_DURATION("map::operator[], with variables");
- map<string,string> strings;
- string key = MakeString();
- string value = MakeString();
- strings[key] = value;
- }
- {
- LOG_DURATION("map::operator[], without variables");
- map<string, string> strings;
- strings[MakeString()] = MakeString();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement