Skip to content

Commit

Permalink
clean up benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
madsbk committed Oct 9, 2024
1 parent 488c060 commit 4832847
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
27 changes: 2 additions & 25 deletions python/kvikio/kvikio/benchmarks/s3_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,32 +102,9 @@ def run() -> float:
yield run()


def run_cudf(args, libcudf_s3_io: bool):
import cudf

cudf.set_option("libcudf_s3_io", libcudf_s3_io)

# Upload data to S3 server
create_client_and_bucket()
data = cupy.random.rand(args.nelem).astype(args.dtype)
df = cudf.DataFrame({"a": data})
df.to_parquet(f"s3://{args.bucket}/data1")

def run() -> float:
t0 = time.perf_counter()
cudf.read_parquet(f"s3://{args.bucket}/data1")
t1 = time.perf_counter()
return t1 - t0

for _ in range(args.nruns):
yield run()


API = {
"cupy-kvikio": partial(run_numpy_like, xp=cupy),
"numpy-kvikio": partial(run_numpy_like, xp=numpy),
"cudf-kvikio": partial(run_cudf, libcudf_s3_io=True),
"cudf-fsspec": partial(run_cudf, libcudf_s3_io=False),
"cupy": partial(run_numpy_like, xp=cupy),
"numpy": partial(run_numpy_like, xp=numpy),
}


Expand Down
29 changes: 29 additions & 0 deletions python/kvikio/tests/test_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,32 @@ def test_http_io(run_cmd, api):
cwd=benchmarks_path,
)
assert retcode == 0


@pytest.mark.parametrize(
"api",
[
"cupy",
"numpy",
],
)
def test_s3_io(run_cmd, api):
"""Test benchmarks/s3_io.py"""

if not kvikio.is_remote_file_available():
pytest.skip(
"RemoteFile not available, please build KvikIO "
"with libcurl (-DKvikIO_REMOTE_SUPPORT=ON)"
)
retcode = run_cmd(
cmd=[
sys.executable,
"http_io.py",
"-n",
"1000",
"--api",
api,
],
cwd=benchmarks_path,
)
assert retcode == 0

0 comments on commit 4832847

Please sign in to comment.