FAQ
Can anyone please suggest me what will be the good way to use matlab
equivalent of "profile clear, profile on, profile off, profile resume
and profile viewer" in Python?

Thanks in advance.

Search Discussions

  • Tim Roberts at Nov 26, 2010 at 6:37 am

    Akand Islam wrote:
    Can anyone please suggest me what will be the good way to use matlab
    equivalent of "profile clear, profile on, profile off, profile resume
    and profile viewer" in Python?
    Python has a number of ways of measuring elapsed time, including the
    "timeit" module and the "trace" module. There's nothing that will display
    the results in a pretty graph, so the answer depends on what you are after.
    --
    Tim Roberts, timr at probo.com
    Providenza & Boekelheide, Inc.
  • Akand Islam at Nov 26, 2010 at 9:15 pm

    On Nov 26, 12:37?am, Tim Roberts wrote:
    Akand Islam wrote:
    Can anyone please suggest me what will be the good way to use matlab
    equivalent of "profile clear, profile on, profile off, profile resume
    and profile viewer" in Python?
    Python has a number of ways of measuring elapsed time, including the
    "timeit" module and the "trace" module. ?There's nothing that will display
    the results in a pretty graph, so the answer depends on what you are after.
    --
    Tim Roberts, t... at probo.com
    Providenza & Boekelheide, Inc.
    Dear Tim Roberts,
    Thanks for your posting. Like, here is the following Matlab codes
    which I am trying to transform into Python. Here you
    will find "profile clear, profile on, profile off, profile resume,
    profile viewer, and drawnow" syntaxes. So, what will be these
    equivalents
    in Python?

    Regards,
    Akand

    ===============================================================================================================
    function x = amg_solve(GUI_HANDLES);

    amg_globals;
    str=get(GUI_HANDLES.panelText,'String');

    %Check the source of the problem specification
    if PROB_SRC==USER_SPEC_FD %if the user finite difference matrix is to
    be used
    str=strcat(str,sprintf('\n Initializing Problem to User
    Specifications '));
    str=strcat(str,sprintf('\n USER: Please enter your input file
    name at the console...'));
    set(GUI_HANDLES.panelText,'String',str);
    drawnow;
    amg_usersetFD; %set up globals as the user has specified them
    elseif PROB_SRC==USER_SPEC_FEM %if the user finite element matrix is
    to be used
    str=strcat(str,sprintf('\n Initializing Problem to User
    Specifications '));
    str=strcat(str,sprintf('\n USER: Please enter your input file
    name at the console...'));
    set(GUI_HANDLES.panelText,'String',str);
    drawnow;
    amg_usersetFEM; %set up globals as the user has specified them
    elseif PROB_SRC==EXAMPLE1 %if example 1 is called for
    str=strcat(str,sprintf('\n Initializing Problem to Poisson
    Example '));
    set(GUI_HANDLES.panelText,'String',str);
    drawnow;
    amg_example1; %set up globals for example 1
    end

    profile clear;

    if SETUP_OPT==AT_ONCE %if user wishes to find all coarse grids up
    front
    % see "restrict.m" for what happens otherwise
    str=strcat(str,sprintf('\n Calling Setup Algorithm to Determine
    Coarse Grids '));
    set(GUI_HANDLES.panelText,'String',str);
    drawnow;
    if SHOW_PROFILE==YES
    profile on;
    end
    amg_setup(1); %call setup algorithm
    if SHOW_PROFILE==YES
    profile off;
    end
    end

    INIT_RESID = norm(RHS - (A(1).matrix * X_Guess)); %get initial
    residual
    str=strcat(str,sprintf('\n 2-Norm of Initial Residual is
    %d ', INIT_RESID));
    set(GUI_HANDLES.panelText,'String',str);
    drawnow;

    x = X_Guess;
    cycleCount = 1; %count the number of AMG cycles executed
    while (cycleCount<=CYCLES)
    str=strcat(str,sprintf('\n Starting AMG Cycle Number
    %i... ', cycleCount));
    set(GUI_HANDLES.panelText,'String',str);
    drawnow;
    if SHOW_PROFILE==YES
    profile resume;
    end
    x = amg_cycle(cycleCount,1,RHS,x); %execute as many AMG cycles if
    necessary
    if SHOW_PROFILE==YES
    profile off;
    end
    str=strcat(str,sprintf('\n 2-Norm of Residual after AMG Cycle
    Number %i is %d ', cycleCount, norm(RH2(cycleCount,1))));
    set(GUI_HANDLES.panelText,'String',str);
    drawnow;
    cycleCount=cycleCount+1; %incriment cycle count
    end

    FINAL_RESID = norm(RHS - (A(1).matrix * x)); %get initial residual

    str=strcat(str,sprintf('\nFinished...
    '));
    set(GUI_HANDLES.panelText,'String',str);
    drawnow;

    if SHOW_PROFILE==YES
    profile viewer;
    end
    ==================================================================================================================================
  • Cameron Simpson at Nov 26, 2010 at 9:50 pm

    On 26Nov2010 13:15, Akand Islam wrote:
    Thanks for your posting. Like, here is the following Matlab codes
    which I am trying to transform into Python. Here you
    will find "profile clear, profile on, profile off, profile resume,
    profile viewer, and drawnow" syntaxes. So, what will be these
    equivalents
    in Python?
    I would start by looking at the "profile" python module:

    http://docs.python.org/library/profile.html#module-profile

    Cheers,
    --
    Cameron Simpson <cs at zip.com.au> DoD#743
    http://www.cskk.ezoshosting.com/cs/

    Their are thre mistakes in this sentence.
    - Rob Ray DoD#33333 <rray at linden.msvu.ca>
  • Akand Islam at Nov 27, 2010 at 12:23 am

    On Nov 26, 3:50?pm, Cameron Simpson wrote:
    On 26Nov2010 13:15, Akand Islam wrote:
    Thanks for your posting. Like, here is the following Matlab codes
    which I am trying to transform into Python. Here you
    will find "profile clear, profile on, profile off, profile resume,
    profile viewer, and drawnow" syntaxes. So, what will be these
    equivalents
    in Python?
    I would start by looking at the "profile" python module:

    ?http://docs.python.org/library/profile.html#module-profile

    Cheers,
    --
    Cameron Simpson <c... at zip.com.au> DoD#743http://www.cskk.ezoshosting.com/cs/

    Their are thre mistakes in this sentence.
    ? ? ? ? - Rob Ray DoD#33333 <r... at linden.msvu.ca>
    Dear Cameron Simpson,
    Thanks for co-operation. I have gone through the link, however, I am
    not much clear. Can you please show me some python syntaxes which
    contain Matlab like "profile on.., drawnow.." and so forth?

    Regards,
    Akand
  • Robert Kern at Nov 27, 2010 at 10:38 pm

    On 2010-11-26 18:23 , Akand Islam wrote:
    On Nov 26, 3:50 pm, Cameron Simpsonwrote:
    On 26Nov2010 13:15, Akand Islamwrote:
    Thanks for your posting. Like, here is the following Matlab codes
    which I am trying to transform into Python. Here you
    will find "profile clear, profile on, profile off, profile resume,
    profile viewer, and drawnow" syntaxes. So, what will be these
    equivalents
    in Python?
    I would start by looking at the "profile" python module:

    http://docs.python.org/library/profile.html#module-profile

    Cheers,
    --
    Cameron Simpson<c... at zip.com.au> DoD#743http://www.cskk.ezoshosting.com/cs/

    Their are thre mistakes in this sentence.
    - Rob Ray DoD#33333<r... at linden.msvu.ca>
    Dear Cameron Simpson,
    Thanks for co-operation. I have gone through the link, however, I am
    not much clear. Can you please show me some python syntaxes which
    contain Matlab like "profile on.., drawnow.." and so forth?
    Perhaps you could explain what those MATLAB commands do. Not everyone here is
    familiar with MATLAB. For the most part, an API like "profile on; profile off"
    is inappropriate for the "profile" Python module. It profiles the times each
    function call takes, not each line. Turning it on and off doesn't make much
    sense. The API described in the above link is better for what it does.

    If you want to visualize the profile, you may want to try RunSnakeRun:

    http://www.vrplumber.com/programming/runsnakerun/

    If you want line-by-line profiling, you may want to check out my package,
    line_profiler:

    http://pypi.python.org/pypi/line_profiler/

    Again, we don't turn it on and off like you might do in MATLAB. Just follow the
    directions and give up trying to find a correspondence with the MATLAB commands.

    --
    Robert Kern

    "I have come to believe that the whole world is an enigma, a harmless enigma
    that is made terrible by our own mad attempt to interpret it as though it had
    an underlying truth."
    -- Umberto Eco
  • Akand Islam at Nov 28, 2010 at 3:10 am

    On Nov 27, 4:38?pm, Robert Kern wrote:
    On 2010-11-26 18:23 , Akand Islam wrote:








    On Nov 26, 3:50 pm, Cameron Simpson<c... at zip.com.au> ?wrote:
    On 26Nov2010 13:15, Akand Islam<sohel... at gmail.com> ?wrote:
    Thanks for your posting. Like, here is the following Matlab codes
    which I am trying to transform into Python. Here you
    will find "profile clear, profile on, profile off, profile resume,
    profile viewer, and drawnow" syntaxes. So, what will be these
    equivalents
    in Python?
    I would start by looking at the "profile" python module:
    ?http://docs.python.org/library/profile.html#module-profile
    Cheers,
    --
    Cameron Simpson<c... at zip.com.au> ?DoD#743http://www.cskk.ezoshosting.com/cs/
    Their are thre mistakes in this sentence.
    ? ? ? ? ?- Rob Ray DoD#33333<r... at linden.msvu.ca>
    Dear Cameron Simpson,
    Thanks for co-operation. I have gone through the link, however, I am
    not much clear. Can you please show me some python syntaxes which
    contain Matlab like "profile on.., drawnow.." and so forth?
    Perhaps you could explain what those MATLAB commands do. Not everyone here is
    familiar with MATLAB. For the most part, an API like "profile on; profile off"
    is inappropriate for the "profile" Python module. It profiles the times each
    function call takes, not each line. Turning it on and off doesn't make much
    sense. The API described in the above link is better for what it does.

    If you want to visualize the profile, you may want to try RunSnakeRun:

    ? ?http://www.vrplumber.com/programming/runsnakerun/

    If you want line-by-line profiling, you may want to check out my package,
    line_profiler:

    ? ?http://pypi.python.org/pypi/line_profiler/

    Again, we don't turn it on and off like you might do in MATLAB. Just follow the
    directions and give up trying to find a correspondence with the MATLAB commands.

    --
    Robert Kern

    "I have come to believe that the whole world is an enigma, a harmless enigma
    ? that is made terrible by our own mad attempt to interpret it as though it had
    ? an underlying truth."
    ? ?-- Umberto Eco
    Dear Robert Kern,
    I do appreciate your reply. Surely I will dig through your package.

    --
    Akand

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedNov 24, '10 at 11:44p
activeNov 28, '10 at 3:10a
posts7
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase