<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 test about profiling
How to profile from a notebook with cProfile, memory_profiler
Step1:  profiling with cProfile
Step2:  Memory profile
Step3:  Thz functions to test must be part of file and cannot be implemented in the notebook. So we save the funtion in script and we import it just after.
Step4:  We run the momory profiling
Step5:  SnakeViz
<ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
Explanation: test about profiling
How to profile from a notebook with cProfile, memory_profiler
End of explanation
def big_list1(n):
    l = []
    for i in range(n):
        l.append(i)
    return l
def big_list2(n):
    return list(range(n))
def big_list(n):
    big_list1(n)
    big_list2(n)
%prun -q -T profile_example.txt -D profile_example.stat big_list(100000) 
with open('profile_example.txt', 'r') as f: content = f.read()
print(content)
import pstats
p = pstats.Stats('profile_example.stat')
p.strip_dirs().sort_stats('cumulative').print_stats()
Explanation: profiling with cProfile
End of explanation
from memory_profiler import memory_usage
mem_usage = memory_usage(-1, interval=.2, timeout=1)
mem_usage
Explanation: Memory profile
End of explanation
%%file script_test.py
def big_list1(n):
    l = []
    for i in range(n):
        l.append(i)
    return l
def big_list2(n):
    return list(range(n))
def big_list(n):
    big_list1(n)
    big_list2(n)
from script_test import big_list, big_list1, big_list2
Explanation: Thz functions to test must be part of file and cannot be implemented in the notebook. So we save the funtion in script and we import it just after.
End of explanation
%load_ext memory_profiler
prof = %mprun -r -f big_list1 -f big_list2 -T profile_example.mem -r big_list(100000)
with open('profile_example.mem', 'r') as f : content = f.read()
print(content)
Explanation: We run the momory profiling:
End of explanation
%load_ext snakeviz
%system snakeviz --help
Explanation: SnakeViz
End of explanation
<END_TASK>