<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Profiling
IPython
Interactive Python provides some Built-in magic commands that can help up when developing code.
?
IPython's help.
Step1:  %quickref
Quick reference.
Step2:  help
Python’s own help system.
Step3:  object?
Details about object. Use object?? for extra details.
Step4:  ! &lt;command&gt;
Forks a shell, run a command in it, exits the shell and returns.
Step5:  %cd
Change the current working directory.
Step6:  who/whos
Print all interactive variables
Step7:  %time &lt;Python statement/expression&gt;
time <Python statement/expression>`
Temporize the execution of a Python statement or expression, remembering its results.
Step8:  %timeit &lt;Python statement/expression&gt;
Really temporize the execution of a Python statement or expression, but forgeting its results.
Step9:  %run &lt;python module&gt;.py
Run the named file inside IPython as a program.
Step10:  %run -t &lt;python module&gt;.py
Giving running times.
Step11:  A longer example (for the sake of the correctness of substract_curves.py)
Step12:  line_profiler
Provides line-by-line running information of decorated methods.
Decorate with @profile those methods you want to profile.
@profile
def profile_me(...)
Step13:  <!-- ## [profile/cProfiler](https
Step14:  Testing Cython
Extracted from this HPC tutorial.
$ pip install cython
<ASSISTANT_TASK:>
Python Code:
?
Explanation: Profiling
IPython
Interactive Python provides some Built-in magic commands that can help up when developing code.
?
IPython's help.
End of explanation
%quickref
Explanation: %quickref
Quick reference.
End of explanation
help
Explanation: help
Python’s own help system.
End of explanation
a = 1
a?
Explanation: object?
Details about object. Use object?? for extra details.
End of explanation
!cd /
!pwd
Explanation: ! &lt;command&gt;
Forks a shell, run a command in it, exits the shell and returns.
End of explanation
%cd /
!pwd
%cd ~/YAPT
!pwd
Explanation: %cd
Change the current working directory.
End of explanation
%whos
Explanation: who/whos
Print all interactive variables
End of explanation
a
%time a=3
a
Explanation: %time &lt;Python statement/expression&gt;
time <Python statement/expression>`
Temporize the execution of a Python statement or expression, remembering its results.
End of explanation
a
%timeit a=4
a
Explanation: %timeit &lt;Python statement/expression&gt;
Really temporize the execution of a Python statement or expression, but forgeting its results.
End of explanation
%run hello_world.py
# %load module.py
a = 1
%run module.py
%whos
a
Explanation: %run &lt;python module&gt;.py
Run the named file inside IPython as a program.
End of explanation
!cat substract_curves.py
!paste dataset1.txt dataset2.txt
%run -t substract_curves.py dataset1.txt dataset2.txt
Explanation: %run -t &lt;python module&gt;.py
Giving running times.
End of explanation
# Generate two "random" similar signals.
import io
import numpy as np
x = 0
base = []
with io.open('dataset3.txt', 'w') as file:
    for i in range(100):
        x += np.random.randint(10) - 4.5
        file.write('{}\t{}\n'.format(i*2,x))
        base.append(x)
with io.open('dataset4.txt', 'w') as file:
    for i in range(99):
        x = base[i] + np.random.randint(10) - 4.5
        file.write('{}\t{}\n'.format(i*2+1,x))
# Run "substract_curves.py" and its stdout is written in "differences.txt". 
import IPython.utils
with IPython.utils.io.capture_output() as captured:
    !python substract_curves.py dataset3.txt dataset4.txt
import io
with io.open('differences.txt', 'w') as file:
    file.write(captured.stdout)
# Plot the signals.
import matplotlib.pyplot as plt
plt.plot(*np.loadtxt("dataset3.txt",unpack=True), linewidth=2.0)
plt.plot(*np.loadtxt("dataset4.txt",unpack=True), linewidth=2.0)
plt.plot(*np.loadtxt("differences.txt",unpack=True), linewidth=2.0)
plt.show()
Explanation: A longer example (for the sake of the correctness of substract_curves.py):
End of explanation
!cat profile_quicksort.py
!kernprof -l -v  profile_quicksort.py
Explanation: line_profiler
Provides line-by-line running information of decorated methods.
Decorate with @profile those methods you want to profile.
@profile
def profile_me(...):
    ...
Profile your module with:
kernprof -l -v &lt;your_module&gt;.py
End of explanation
<!-- !python -m cProfile quicksort.py -->
Explanation: <!-- ## [profile/cProfiler](https://docs.python.org/3.6/library/profile.html) 
Return running information about every method called from your code.-->
<!-- !cat quicksort.c ->
End of explanation
%load_ext Cython
def f_slow(i):
    return i**4 + 3*i**2 + 10
%timeit f_slow(100)
%%cython --annotate
def f_cython(int i):
    return i**4 + 3*i**2 + 10
%timeit f_cython(100)
Explanation: Testing Cython
Extracted from this HPC tutorial.
$ pip install cython
End of explanation
<END_TASK>