sc_profiling#

Profiling and CPU/memory management functions.

Highlights:

Classes

cprofile

Function profiler, built off Python's built-in cProfile

resourcemonitor

Asynchronously monitor resource (e.g. memory) usage and terminate the process if the specified threshold is exceeded.

Functions

checkmem

Checks how much memory the variable or variables in question use by dumping them to file.

checkram

Measure actual memory usage, typically at different points throughout execution.

benchmark

Benchmark Python performance

cpu_count

Alias to multiprocessing.cpu_count()

cpuload

Takes a snapshot of current CPU usage via psutil

memload

Takes a snapshot of current fraction of memory usage via psutil

loadbalancer

Delay execution while CPU load is too high -- a very simple load balancer.

profile

Profile the line-by-line time required by a function.

mprofile

Profile the line-by-line memory required by a function.

Exceptions

LimitExceeded

Custom exception for use with the sc.resourcemonitor() monitor.