Skip to content

Async

Benchmarks the time taken for asynchronous data filtering using the AsyncGrid3 class.

This function initializes an AsyncGrid3 instance, performs an asynchronous filter operation on a specific dataset ("NGA_HealthFacilities_v1_72") and state ("abuja"), and prints the time taken for this operation.

Example

await benchmark_async()

Note

The performance results will vary based on the dataset size and system specifications.

Source code in nigeria_geodata/benchmark.py
async def benchmark_async():
    """
    Benchmarks the time taken for asynchronous data filtering using the AsyncGrid3 class.

    This function initializes an AsyncGrid3 instance, performs an asynchronous filter operation
    on a specific dataset ("NGA_HealthFacilities_v1_72") and state ("abuja"), and
    prints the time taken for this operation.

    Example:
        await benchmark_async()

    Note:
        The performance results will vary based on the dataset size and system specifications.
    """
    grid3 = AsyncGrid3()
    start_time = time.time()
    await grid3.filter("NGA_HealthFacilities_v1_72", "abuja")
    elapsed_time = time.time() - start_time
    print(f"Asynchronous call took {elapsed_time:.2f} seconds")

Sync

Benchmarks the time taken for synchronous data filtering using the Grid3 class.

This function initializes a Grid3 instance, performs a synchronous filter operation on a specific dataset ("NGA_HealthFacilities_v1_72") and state ("abuja"), and prints the time taken for this operation.

Example

benchmark_sync()

Note

The performance results will vary based on the dataset size and system specifications.

Source code in nigeria_geodata/benchmark.py
def benchmark_sync():
    """
    Benchmarks the time taken for synchronous data filtering using the Grid3 class.

    This function initializes a Grid3 instance, performs a synchronous filter operation
    on a specific dataset ("NGA_HealthFacilities_v1_72") and state ("abuja"), and
    prints the time taken for this operation.

    Example:
        benchmark_sync()

    Note:
        The performance results will vary based on the dataset size and system specifications.
    """
    grid3 = Grid3()
    start_time = time.time()
    grid3.filter(
        "NGA_HealthFacilities_v1_72",
        "abuja",
    )
    elapsed_time = time.time() - start_time
    print(f"Synchronous call took {elapsed_time:.2f} seconds")

Results

  • sync took 4.58 seconds.
  • async took 0.98 seconds.
  • machine - MBP 16inch. M3, 36 GB RAM.