from detkit import Profile, memdet, human_readable_time, \
human_readable_mem
# Create a random matrix
import numpy
A = numpy.random.randn(10000, 10000)
# Initialize profile
prof = Profile()
# Set the starting point of memory inquiry
prof.set()
# Perform a memory-intensive operation
ld = memdet(A)
# Inquiry wall time
print(human_readable_time(prof.wall_time()))
# Inquiry process time
print(human_readable_time(prof.proc_time()))
# Check CPU utilization (in percent)
print(prof.cpu_utilization())
# Inquiry the current memory allocation
print(human_readable_mem(prof.mem_now()))
# Inquiry the peak memory allocation
print(human_readable_mem(prof.mem_peak()))
# Inquiry read from disk during the above operation
print(prof.disk_read())
# Inquiry write to disk during the above operation, in MB unit
print(prof.disk_write())
# Inquiry write to disk during the above operation, in MB unit
prof.print_profile(shape=A.shape, dtype=A.dtype)
5.0 sc 18.6 sc 50.5120804652939 88.1 KB 763.2 MB 0.0 0.0 | time: 5.1 sc | cpu: 50% | alloc: 763.2 MB | read: 0 B | write: 0 B |