Skip to content

Commit

Permalink
add client_test option for disk I/O backend
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Aug 15, 2022
1 parent 943917e commit b5dd3a3
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions examples/client_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ see LICENSE file.
#include "libtorrent/write_resume_data.hpp"
#include "libtorrent/string_view.hpp"
#include "libtorrent/disk_interface.hpp" // for open_file_state
#include "libtorrent/disabled_disk_io.hpp" // for disabled_disk_io_constructor
#include "libtorrent/load_torrent.hpp"

#include "libtorrent/mmap_disk_io.hpp"
#include "libtorrent/posix_disk_io.hpp"
#include "libtorrent/pread_disk_io.hpp"
#include "libtorrent/disabled_disk_io.hpp"

#include "torrent_view.hpp"
#include "session_view.hpp"
#include "print.hpp"
Expand Down Expand Up @@ -1186,7 +1190,10 @@ CLIENT OPTIONS
-e <loops> exit client after the specified number of iterations
through the main loop
-O print session stats counters to the log
-1 exit on first torrent completing (useful for benchmarks))"
-1 exit on first torrent completing (useful for benchmarks)
-i <disk-io> specify which disk I/O back-end to use. One of:
mmap, posix, pread, disabled
)"
#ifdef TORRENT_UTP_LOG_ENABLE
R"(
-q Enable uTP transport-level verbose logging
Expand All @@ -1209,12 +1216,7 @@ BITTORRENT OPTIONS
NETWORK OPTIONS
-x <file> loads an emule IP-filter file
-Y Rate limit local peers
)"
#if TORRENT_USE_I2P
R"( -i <i2p-host> the hostname to an I2P SAM bridge to use
)"
#endif
R"(
DISK OPTIONS
-a <mode> sets the allocation mode. [sparse|allocate]
-0 disable disk I/O, read garbage and don't flush to disk
Expand Down Expand Up @@ -1396,6 +1398,25 @@ int main(int argc, char* argv[])
break;
case 'T': max_connections_per_torrent = atoi(arg); break;
case 'r': peer = arg; break;
case 'i': {
#if TORRENT_HAVE_MMAP || TORRENT_HAVE_MAP_VIEW_OF_FILE
if (arg == "mmap"_sv)
params.disk_io_constructor = lt::mmap_disk_io_constructor;
else
#endif
if (arg == "posix"_sv)
params.disk_io_constructor = lt::posix_disk_io_constructor;
else if (arg == "pread"_sv)
params.disk_io_constructor = lt::pread_disk_io_constructor;
else if (arg == "disabled"_sv)
params.disk_io_constructor = lt::disabled_disk_io_constructor;
else
{
std::fprintf(stderr, "unknown disk-io subsystem: \"%s\"\n", arg);
std::exit(1);
}
break;
}
case 'e':
{
loop_limit = atoi(arg);
Expand Down

0 comments on commit b5dd3a3

Please sign in to comment.