Skip to content

Commit

Permalink
Remove Dask dependency
Browse files Browse the repository at this point in the history
Change clock to `time.monotonic()`, to prevent issues with clock
going backwards in some systems.
  • Loading branch information
pentschev committed Aug 5, 2022
1 parent b385060 commit f8969f2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
11 changes: 7 additions & 4 deletions benchmarks/cudf-merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
import os
import pickle
import pstats
from time import perf_counter as clock
from time import monotonic as clock

import cupy
import numpy as np

from dask.utils import format_bytes, format_time

import ucp
from ucp._libs.utils import print_multi, print_separator
from ucp._libs.utils import (
format_bytes,
format_time,
print_multi,
print_separator,
)
from ucp.utils import hmean, run_on_local_network

# Must be set _before_ importing RAPIDS libraries (cuDF, RMM)
Expand Down
12 changes: 11 additions & 1 deletion ucp/_libs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,19 @@ def nvtx_annotate(message=None, color=None, domain=None):


try:
from dask.utils import format_bytes, parse_bytes
from dask.utils import format_bytes, format_time, parse_bytes
except ImportError:

def format_time(x):
if x < 1e-6:
return f"{x * 1e9:.3f} ns"
if x < 1e-3:
return f"{x * 1e6:.3f} us"
if x < 1:
return f"{x * 1e3:.3f} ms"
else:
return f"{x:.3f} s"

def format_bytes(x):
"""Return formatted string in B, KiB, MiB, GiB or TiB"""
if x < 1024:
Expand Down

0 comments on commit f8969f2

Please sign in to comment.