Konverter Kecepatan Transfer Data
Konversi antara Mbps, MB/s, Gbps, KB/s, dan unit kecepatan internet lainnya.
Pertanyaan yang Sering Diajukan
Implementasi Kode
# Data Transfer Speed Converter
# Bits vs Bytes: 1 byte = 8 bits
def mbps_to_mbs(mbps: float) -> float:
"""Megabits/s β Megabytes/s (divide by 8)."""
return mbps / 8
def mbs_to_mbps(mbs: float) -> float:
"""Megabytes/s β Megabits/s (multiply by 8)."""
return mbs * 8
def gbps_to_tbh(gbps: float) -> float:
"""Gigabits/s β Terabytes/hour."""
# 1 Gbps = 0.125 GB/s = 0.125 * 3600 GB/h = 450 GB/h = 0.439 TB/h
gb_per_hour = gbps * 0.125 * 3600
return gb_per_hour / 1024 # Convert GB to TB
def download_time_seconds(file_size_mb: float, speed_mbps: float) -> float:
"""Calculate download time given file size (MB) and connection speed (Mbps)."""
speed_mbs = mbps_to_mbs(speed_mbps)
return file_size_mb / speed_mbs
def format_time(seconds: float) -> str:
if seconds < 60:
return f"{seconds:.1f} seconds"
elif seconds < 3600:
return f"{seconds / 60:.1f} minutes"
else:
return f"{seconds / 3600:.2f} hours"
# Examples
speed_mbps = 100 # 100 Mbps connection
print(f"{speed_mbps} Mbps = {mbps_to_mbs(speed_mbps)} MB/s")
# 100 Mbps = 12.5 MB/s
# Download time for common file sizes
files = [
("1 GB movie", 1024),
("4 GB game", 4096),
("50 GB game", 51200),
]
for name, size_mb in files:
t = download_time_seconds(size_mb, speed_mbps)
print(f" {name}: {format_time(t)}")
# 1 GB movie: 1.4 minutes
# 4 GB game: 5.5 minutes
# 50 GB game: 1.14 hoursComments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.