yum install sysstat
mpstat
mpstat -P ALL
sar
To get multiple samples and multiple reports set an output filefor the sar command. Run the sar command as a background process using.
# sar -o output.file 12 8 >/dev/null 2>&1 &
Better use nohupcommand so that you can logout and check back report later on:
# nohup sar -o output.file 12 8 >/dev/null 2>&1 &
All data is captured in binary form and saved to a file(data.file). The data can then be selectively displayed ith the sar command using the -f option.
# sar -f data.file
iostat
python3.6-m timeit -n 5-r 5-s "import julia1" "julia1│sys 0m0.000s
.calc_pure_python(draw_output=True, desired_width=1000, max_iterations=300)# ipython%timeit calc_pure_python(draw_output=True, desired_width=1000, max_iterations=300)# shell/usr/bin/time -p python julia1_nopil.py
# out
real # all time
user # cup time but not contain kernal function time
sys # kernal function time
sys + user <= real because wait i/o
# contain time of start Interpreter[root@test-server cpu_profiling]# /usr/bin/time --verbose python3.6 julia1_nopil.py
Length of x:1000
Total elements:1000000
calculate_z_serial_purepython took 7.895394802093506 seconds
Command being timed:"python3.6 julia1_nopil.py"
User time (seconds):8.45
System time (seconds):0.05
Percent of CPU this job got:99%
Elapsed (wall clock) time (h:mm:ss or m:ss):0:08.51
Average shared text size (kbytes):0
Average unshared data size (kbytes):0
Average stack size (kbytes):0
Average total size (kbytes):0
Maximum resident set size (kbytes):96712
Average resident set size (kbytes):0
Major (requiring I/O) page faults:0# read page from hand to RAM # 内存密集型有
Minor (reclaiming a frame) page faults:26283
Voluntary context switches:1
Involuntary context switches:95
Swaps:0
File system inputs:0
File system outputs:0
Socket messages sent:0
Socket messages received:0
Signals delivered:0
Page size (bytes):4096
Exit status:0[root@ecpro-draw-app-test-server cpu_profiling]# python3.6 -m cProfile -s cumulative julia1_nopil.py
Length of x:1000
Total elements:1000000
calculate_z_serial_purepython took 11.42645788192749 seconds
36221995 function calls in12.236 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)10.0000.00012.23612.236{built-in method builtins.exec}10.0330.03312.23612.236 julia1_nopil.py:1(<module>)10.6380.63812.20412.204 julia1_nopil.py:25(calc_pure_python)18.3768.37611.42611.426 julia1_nopil.py:9(calculate_z_serial_purepython)342199803.0500.0003.0500.000{built-in method builtins.abs}20020000.1330.0000.1330.000{method 'append' of 'list' objects}10.0060.0060.0060.006{built-in method builtins.sum}30.0000.0000.0000.000{built-in method builtins.print}40.0000.0000.0000.000{built-in method builtins.len}20.0000.0000.0000.000{built-in method time.time}10.0000.0000.0000.000{method 'disable' of '_lsprof.Profiler' objects}# python3.6 -m cProfile -o profile.stats -s cumulative julia1.pyimport pstats
In [6]: p = pstats.Stats("profile.stats")
In [7]: p.sort_stats("cumulative")
Out[7]:<pstats.Stats at 0x7fed02abfbe0>
In [8]: p.print_stats()
Thu Apr 420:48:132019 profile.stats
36252766 function calls (36251973 primitive calls)in12.711 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)62/10.0030.00012.71112.711{built-in method builtins.exec}10.0450.04512.71112.711 julia1.py:1(<module>)10.6530.65312.64912.649 julia1.py:78(calc_pure_python)18.3918.39111.46811.468 julia1.py:63(calculate_z_serial_purepython)342199803.0760.0003.0760.000{built-in method builtins.abs}10.0290.0290.3760.376 julia1.py:25(show_greyscale)10.2070.2070.2070.207 julia1.py:32(<listcomp>)20030060.1460.0000.1460.000{method 'append' of 'list' objects}10.0000.0000.1220.122/usr/local/lib64/python3.6/site-packages/PIL/Image.py:2021(show)10.0000.0000.1220.122/usr/local/lib64/python3.6/site-packages/PIL/Image.py:2904(_show)10.0000.0000.1220.122/usr/local/lib64/python3.6/site-packages/PIL/Image.py:2909(_showxv)75/90.0000.0000.1200.013<frozen importlib._bootstrap>:966(_find_and_load)75/90.0000.0000.1190.013<frozen importlib._bootstrap>:936(_find_and_load_unlocked)111/100.0000.0000.1190.012<frozen importlib._bootstrap>:211(_call_with_frames_removed)144/100.0000.0000.1190.012<frozen importlib._bootstrap>:997(_handle_fromlist)22/80.0000.0000.1190.015{built-in method builtins.__import__}71/90.0000.0000.1190.013<frozen importlib._bootstrap>:651(_load_unlocked)53/80.0000.0000.1180.015<frozen importlib._bootstrap_external>:672(exec_module)530.0000.0000.0830.002<frozen importlib._bootstrap_external>:743(get_code)530.0000.0000.0800.002<frozen importlib._bootstrap_external>:485(_compile_bytecode)530.0800.0020.0800.002{built-in method marshal.loads}10.0000.0000.0700.070/usr/local/lib64/python3.6/site-packages/PIL/ImageShow.py:43(show)
p.print_callees()
yum install sysstatmpstat mpstat -P ALLsarTo get multiple samples and multiple reports set an output file for the sar command. Run the sar command as a background process using.# sar -o output....