Skip to content

Benchmark Utilities

filesender.benchmark.benchmark

benchmark(
    paths: List[Path],
    limit: int,
    base_url: str,
    username: str,
    apikey: str,
    recipient: str,
) -> List[BenchResult]

Runs a test upload using a variety of semaphore settings, and return one result for each.

Parameters:

Name Type Description Default
paths List[Path]

A list of files to upload. Typically generated by make_tempfiles

required
limit int

The value for concurrent_chunks in the FileSenderClient constructor

required
base_url str

The FileSender instance URL

required
username str

Your username for accessing the FileSender instance

required
apikey str

Your API key for accessing the FileSender instance

required
recipient str

A valid email address that will be sent the files

required

filesender.benchmark.BenchResult dataclass

BenchResult(
    time: float, memory: int, concurrent_chunks: int
)

The result of a single benchmark execution

concurrent_chunks instance-attribute

concurrent_chunks: int

memory instance-attribute

memory: int

Memory in bytes

time instance-attribute

time: float

Memory in fractional sections

filesender.benchmark.make_tempfiles

make_tempfiles(
    size: int, n: int = 2, **kwargs: Any
) -> Generator[List[Path], Any, None]

Makes n temporary files of size size and yields them as a list via context manager.

Example
with make_tempfiles(size=100_000_000) as files:
    ...

Parameters:

Name Type Description Default
size int

The size of each file in bytes

required
n int

The number of files to generate

2
kwargs Any

Additional args to pass to [tempfile.NamedTemporaryFile]

{}