jed-users mailing list

[2008 Date Index] [2008 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [RFC/RFT] format_paragraph for JLM


G. Milde <milde@xxxxxxxxxxxxxxxxxxxxx> wrote:
> Did you perceive or measure the time it costs to determine these in an
> indent_hook? It is my expectation that a perceptible delay will only
> occur if the hook is used in a loop (e.g. with indent_region).

You might be able to use the slang profiler for this.  I hope to
integrate the profiler into jed to make this simple.  For now, I hope
that the following example will suffice.  This example is also
instructive in the sense that it shows that if you have to use a
for-loop in slang, then you should use the _for form.  It also shows
that it is best to avoid loops altogether if possible by taking
advantage of arrays (more than 100x faster in this example).

The code (foo.sl) to be profiled, and its profile report are appended
below.  Thanks, --John

--------------------------------------------------------------------------
require ("profile");

profile_on(1);    % Generate profiling code for the following

define test_for (n)
{
   variable i, s = 0.0;
   for (i = 0; i < n; i++)
     s += i;
   return s;
}

define test_alt_for (n)
{
   variable i, s = 0.0;
   _for i (0, n-1, 1)
     s += i;
   return s;
}

define test_foreach (n)
{
   variable i, s = 0.0;
   foreach i ([0:n-1])
     s += i;
   return s;
}

define test_sum (n)
{
   return sum ([0:n-1]);
}
     
define test ()
{
   variable s, n = 100000;
   s = test_for (n);
   s = test_alt_for (n);
   s = test_foreach (n);
   s = test_sum (n);
}

profile_off ();    % Turn off the generation of profiling code

profile_calibrate ();
profile_begin (1);   % Enable profiling hooks and gather data
test ();
profile_end ();      % Disable profiling hooks

profile_report (fopen ("/tmp/test.prof", "w"));
-----------------------------------------------------------------

#----------------------------------------------------------------
#                  Function Call Profile Report
#----------------------------------------------------------------

#function                 ncalls      ms/call  totalselfms    totalsecs Function File
test_for                       1     752.3228     752.3228       0.7523       0  300004 /tmp/foo.sl
test_foreach                   1     278.8604     278.8604       0.2789       0  100003 /tmp/foo.sl
test_alt_for                   1     266.1934     266.1934       0.2662       0  100003 /tmp/foo.sl
test_sum                       1       2.1907       2.1907       0.0022       0       1 /tmp/foo.sl
test                           1    1299.5792       0.0120       1.2996       4       5 /tmp/foo.sl

#----------------------------------------------------------------
#                  Line by Line Profile Report
#----------------------------------------------------------------

#ncalls      ms/call totalselfms     totalsecs  Fcalls   Scalls File:line
 100000      0.00028     28.20335      0.02820       0       0 /tmp/foo.sl:9
 100000      0.00028     27.64835      0.02765       0       0 /tmp/foo.sl:25
 100000      0.00027     27.33735      0.02734       0       0 /tmp/foo.sl:17
 200002      0.00008     15.36406      0.01536       0       0 /tmp/foo.sl:8
      1      2.18468      2.18468      0.00218       0       0 /tmp/foo.sl:31
      1   1299.58478      0.00557      1.29958       5  500016 /tmp/foo.sl:47
      1      0.00268      0.00268      0.00000       0       0 /tmp/foo.sl:24
      1      0.00068      0.00068      0.00000       0       0 /tmp/foo.sl:18
      1      0.00068      0.00068      0.00000       0       0 /tmp/foo.sl:10
      1      0.00068      0.00068      0.00000       0       0 /tmp/foo.sl:15
      1      0.00068      0.00068      0.00000       0       0 /tmp/foo.sl:23
      1      2.19126      0.00057      0.00219       1       1 /tmp/foo.sl:40
      1     -0.00032     -0.00032     -0.00000       0       0 /tmp/foo.sl:16
      1     -0.00032     -0.00032     -0.00000       0       0 /tmp/foo.sl:26
      1     -0.00032     -0.00032     -0.00000       0       0 /tmp/foo.sl:7
      1     -0.00032     -0.00032     -0.00000       0       0 /tmp/foo.sl:36
      1    278.85996     -0.00043      0.27886       1  100003 /tmp/foo.sl:39
      1    752.32234     -0.00043      0.75232       1  300004 /tmp/foo.sl:37
      1    266.19296     -0.00043      0.26619       1  100003 /tmp/foo.sl:38
      1     -0.00232     -0.00232     -0.00000       0       0 /tmp/foo.sl:48

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2008 date index] [2008 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]