from typing import Union
import time


def time_ms(as_float: bool = False) -> Union[int, float]:
    """Convert current time to milliseconds.

    :param as_float: result should be float, default result is int
    :return: current time in milliseconds
    """
    _time_ms = time.time() * 1000
    if not as_float:
        return int(_time_ms)
    return _time_ms