Re: Timing of statements inside a cell
- To: mathgroup at smc.vnet.net
- Subject: [mg50852] Re: [mg50841] Timing of statements inside a cell
- From: János <janos.lobb at yale.edu>
- Date: Fri, 24 Sep 2004 04:41:26 -0400 (EDT)
- References: <200409230927.FAA08079@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
To answer my own question, wrapping Timing with a Print works just fine
from inside the cell. I found it shortly after I sent my e-mail to the
group. Sorry...
My other question is still pending regarding the replacement of Append
with REAP and SOW. I read all I could on it in the Book, I looked many
archived messages, but my brain is still not on it.
János
On Sep 23, 2004, at 5:27 AM, János wrote:
> Hi,
>
> I have a cell with some code in it containing many statements. Like:
>
> Cell starts here
> ...
> ...
> currentTargetPartitioned = Partition[currentTarget, primerLength, 1];
> prposBin = {{1}, {currentTargetLength}};
>
> (* Do as long as the Mean of
> the distance between
> neighbouring primers is bigger than averagePrimerDistance *)
> While[Mean[Flatten[Map[#[[2]] - #[[1]] &, Partition[prposBin, 2, 1]]] ]
>> \
> averagePrimerDistance, (
> pr = random[currentTargetPartitioned];
> prpos = Position[currentTargetPartitioned, pr];
> prposBin = Sort[Flatten[Append[prposBin, Flatten[prpos] ] ] ];
> )];
>
> (* Create a double strand
> from the currentTarget in such a way that the double
> starts
> from
> the first primer position and file it into collectedDnaBin *)
> prposBinDouble = Most[Map[{#, Last[prposBin]} &, prposBin] ];
> collectpr = Take[currentTarget, prposBinDouble[[2]] ];
> ...
> ...
> Cell ends here
>
> I would like to time every single statement as they are executing.
> Just adding //Timing after every statement or wrapping them with
> Timing[statement;] does not work.
> Any good hint ? /I am sure I am not the only one needing it :)/
>
> In general, what kind of profiling Mathematica allows to pinpoint the
> statements inside a single cell which spend the most time in the kernel
> ?
>
> If it cannot be done inside a cell, what is possible baring to break
> the cell into single statements cells ? What should I read ?
>
> Other question: In the While loop above I am collecting positions into
> a list
> prposBin = Sort[Flatten[Append[prposBin, Flatten[prpos] ] ] ];
> /Just realized that I should do the Sort outside of the loop :)/
> How can I do the collection with Sow and Reap to avoid Append ?
>
> Thanks ahead,
>
> János
> P.S.
> ----------------------------------------------
> Trying to argue with a politician is like lifting up the head of a
> corpse.
> (S. Lem: His Master Voice)
>
>
-------------------------------------------------------------------
János Löbb
Yale University School of Medicine
Department of Pathology
Phone: 203-737-5204
Fax: 203-785-7303
E-mail: janos.lobb at yale.edu
- References:
- Timing of statements inside a cell
- From: János <janos.lobb@yale.edu>
- Timing of statements inside a cell