MCPcopy Create free account
hub / github.com/arvidn/libtorrent / run_test

Function run_test

tools/checking_benchmark.cpp:120–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120void run_test(std::string const& save_path, lt::create_flags_t const flags
121 , lt::disk_io_constructor_type disk)
122{
123 auto const torrent_buf = generate_torrent(7000, save_path, flags);
124
125 std::cout << "drop caches now. e.g. \"echo 1 | sudo tee /proc/sys/vm/drop_caches\"\n";
126 std::cout << "press enter to continue\n";
127
128 char dummy;
129 std::cin.read(&dummy, 1);
130
131 lt::session_params params;
132 params.disk_io_constructor = disk;
133 auto& s = params.settings;
134 s.set_bool(lt::settings_pack::enable_dht, false);
135 s.set_bool(lt::settings_pack::enable_upnp, false);
136 s.set_bool(lt::settings_pack::enable_natpmp, false);
137 s.set_bool(lt::settings_pack::enable_lsd, false);
138 s.set_int(lt::settings_pack::hashing_threads, 1);
139 s.set_int(lt::settings_pack::alert_mask
140 , lt::alert_category::error | lt::alert_category::storage | lt::alert_category::status);
141 s.set_str(lt::settings_pack::listen_interfaces, "");
142
143 lt::session ses(params);
144 lt::add_torrent_params atp = lt::load_torrent_buffer(torrent_buf);
145 atp.save_path = save_path;
146 atp.flags &= ~(lt::torrent_flags::paused | lt::torrent_flags::auto_managed);
147 lt::torrent_handle h = ses.add_torrent(atp);
148 auto const start = lt::clock_type::now();
149 for (;;)
150 {
151 ses.wait_for_alert(5s);
152 std::vector<lt::alert*> alerts;
153 ses.pop_alerts(&alerts);
154 for (lt::alert const* a : alerts)
155 {
156 std::cout << a->message() << '\n';
157 if (auto const* sca = lt::alert_cast<lt::state_changed_alert>(a))
158 {
159 if (sca->state != lt::torrent_status::checking_files
160 && sca->state != lt::torrent_status::checking_resume_data)
161 goto done;
162 }
163 }
164 }
165done:
166 auto const end = lt::clock_type::now();
167 std::cout << "\n\nduration: "
168 << (std::chrono::duration_cast<milliseconds>(end - start).count() / 1000.)
169 << "s\n";
170}
171
172}
173

Callers 1

mainFunction · 0.70

Calls 12

load_torrent_bufferFunction · 0.85
nowFunction · 0.85
set_boolMethod · 0.80
set_intMethod · 0.80
set_strMethod · 0.80
generate_torrentFunction · 0.70
readMethod · 0.45
add_torrentMethod · 0.45
wait_for_alertMethod · 0.45
pop_alertsMethod · 0.45
messageMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected