Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #29051

Re: Measuring execution speed -- profiling in Forth?

From Bernd Paysan <bernd.paysan@gmx.de>
Newsgroups comp.lang.forth
Subject Re: Measuring execution speed -- profiling in Forth?
Date 2014-03-17 01:32 +0100
Organization 1&1 Internet AG
Message-ID <lg5frb$mph$1@online.de> (permalink)
References <qdm8i912ie2rkiq7vs310hq3uk0ubud3mj@4ax.com> <21472b76-85c6-45ac-99b9-28eaf4004483@googlegroups.com>

Show all headers | View raw


foxaudioresearch@gmail.com wrote:

> This goes way back and I can't put my fingers on the code right now, but I
> recall an article in Forth Dimensions (maybe?) where ':' was re-defined to
> add profiling to every word after the re-defined version was in the
> system.
> 
> Does anyone else remember that or am I delusional?

That's one possibility; you'll get a count, how often each word is called.

Gforth git has a word TIMER: (in assert.fs), you cam define several times to 
time different parts of the code.  My convention is that each timer starts 
with a +, and you define a generic timer +REST.  If you want to check how 
much a particular word contributes to the overall run-time, you define this 
word (let's call it FOO) as follows:

timer: +rest
timer: +foo

: foo ( in -- out ) +rest \ does something which needs to be timed
  bla bla  +foo ;

.TIMES will print out all timers (in reverse order of their definition).  
Whether the timing actually is measured depends on the switch PROFILE(, 
which you can turn on with +DB PROFILE( and off with -DB PROFILE( (it's 
turned on by default).  It is supposed that you say PROFILE( .TIMES ) so 
that you get the timers output only when you are in profiling mode.  This is 
the actual run-time in nanoseconds plus overhead of the measurement...

This code is still experimental, comments welcome.

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Measuring execution speed -- profiling in Forth? Assad <assad.ebrahim@alum.swarthmore.edu> - 2014-03-15 13:48 +0000
  Re: Measuring execution speed -- profiling in Forth? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-03-15 14:40 +0000
    Re: Measuring execution speed -- profiling in Forth? David Kuehling <dvdkhlng@posteo.de> - 2014-03-17 08:00 +0100
    Re: Measuring execution speed -- profiling in Forth? Assad Ebrahim <assad.ebrahim@alum.swarthmore.edu> - 2014-04-01 12:18 +0100
  Re: Measuring execution speed -- profiling in Forth? "Elizabeth D. Rather" <erather@forth.com> - 2014-03-15 11:40 -1000
  Re: Measuring execution speed -- profiling in Forth? foxaudioresearch@gmail.com - 2014-03-16 15:50 -0700
    Re: Measuring execution speed -- profiling in Forth? "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-03-16 20:24 -0400
    Re: Measuring execution speed -- profiling in Forth? Bernd Paysan <bernd.paysan@gmx.de> - 2014-03-17 01:32 +0100
  Re: Measuring execution speed -- profiling in Forth? Coos Haak <chforth@hccnet.nl> - 2014-03-17 01:32 +0100
    Re: Measuring execution speed -- profiling in Forth? m.a.m.hendrix@tue.nl - 2014-03-17 01:07 -0700
  Re: Measuring execution speed -- profiling in Forth? "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-03-17 03:33 -0400
    Re: Measuring execution speed -- profiling in Forth? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-03-20 20:43 +0000
      Re: Measuring execution speed -- profiling in Forth? "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-03-20 18:54 -0400
  Re: Measuring execution speed -- profiling in Forth? Assad <assad.ebrahim@alum.swarthmore.edu> - 2014-03-17 08:23 +0000

csiph-web