ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Thomas A. Schmitz" <thomas.schmitz@uni-bonn.de>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
	Hans Hagen <j.hagen@xs4all.nl>
Subject: [NTG-context] Re: save runtime information
Date: Wed, 20 Nov 2024 22:10:56 +0100	[thread overview]
Message-ID: <e5d758f0-793b-4eca-8d43-1e510e225ac3@uni-bonn.de> (raw)
In-Reply-To: <f8a6abc8-8da6-4976-8aa5-164e8cc657e7@xs4all.nl>

Thank you, Hans! I am playing with it right now and will try to add a 
simple example to the wiki. For the time being, I just want to keep some 
sort of statistics around, also to measure performance of my computers 
and servers. Since the log file will be read and written to by other 
programs as well, I'm keeping it very simple, in a text format, so I 
simplify your code a bit, maybe that's a good starting point for others 
on the wiki to elaborate.

All best

Thomas

On 11/20/24 9:10 AM, Hans Hagen wrote:
> Ah, you're trying to locate bottlenecks ... you need to register timing 
> pretty late, like this:
> 
> \startluacode
> luatex.wrapup (
>      function()
>          --
>          print("saving runtime in foo.txt")
>          io.savedata("foo.txt",statistics.elapsedtime(lua.getruntime()))
>          --
>          local t = {
>              runtime = statistics.elapsedtime(lua.getruntime()),
>              mytime  = statistics.elapsedtime("foo"),
>          }
>          print("saving runtime in foo.lua")
>          table.save("foo.lua",t)
>          --
>      end
> )
> \stopluacode
> 
> \starttext
> 
> % it's showtime:
> 
> runtime : \cldcontext {
>      io.loaddata("foo.txt")
> }
> 
> mytime: \cldcontext {
>      ( table.load("foo.lua") or { } ).mytime
> }
> 
> % let's waste some time:
> 
> \ctxlua{statistics.starttiming("foo")}
> \dorecurse{500}{
>      \glyphxscale\numexpr1000-#1\relax
>      \samplefile{knuthmath}
>      \blank
> }
> \ctxlua{statistics.stoptiming("foo")}
> 
> \stoptext
> 
> Wikifying a better example probably takes more time than this run,
> 
> Hans


-- 
Prof. Dr. Thomas A. Schmitz
Institut für Klassische und Romanische Philologie
Universität Bonn
Rabinstr. 8
53111 Bonn
http://www.philologie.uni-bonn.de/de/personal/schmitz
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

      reply	other threads:[~2024-11-20 21:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-19 22:38 [NTG-context] " Thomas A. Schmitz
2024-11-20  8:10 ` [NTG-context] " Hans Hagen
2024-11-20 21:10   ` Thomas A. Schmitz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e5d758f0-793b-4eca-8d43-1e510e225ac3@uni-bonn.de \
    --to=thomas.schmitz@uni-bonn.de \
    --cc=j.hagen@xs4all.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).