* Automatically loading the page state, LoadPageState
@ 2013-10-01 12:15 Marco Patzer
2013-10-01 12:36 ` Marco Patzer
2013-10-01 13:06 ` Hans Hagen
0 siblings, 2 replies; 6+ messages in thread
From: Marco Patzer @ 2013-10-01 12:15 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 930 bytes --]
Hi,
I wonder if it's necessary to manually load the MetaPost variables
using LoadPageState. Some of them are static and do not require an
update on each page, e.g. NOfPages, but many of them might change on
each page, e.g. OnOddPage, PageNumber, TextWidth. Forgetting to use
LoadPageState easily results in perfectly valid code producing wrong
results, which might not be hard to spot. Example:
\setuplayout [width=10cm]
\showframe
\starttext
\startMPcode
fill unitsquare xyscaled (\the\textwidth, 2cm);
\stopMPcode
\startMPcode
fill unitsquare xyscaled (TextWidth, 2cm);
\stopMPcode
\startMPcode
LoadPageState;
fill unitsquare xyscaled (TextWidth, 2cm);
\stopMPcode
\stoptext
I assume it's too inefficient to load the page state automatically
for each graphic. However, loading the page state automatically is
simple:
\startMPinitializations
LoadPageState;
\stopMPinitializations
Marco
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Automatically loading the page state, LoadPageState
2013-10-01 12:15 Automatically loading the page state, LoadPageState Marco Patzer
@ 2013-10-01 12:36 ` Marco Patzer
2013-10-01 13:20 ` Hans Hagen
2013-10-01 13:06 ` Hans Hagen
1 sibling, 1 reply; 6+ messages in thread
From: Marco Patzer @ 2013-10-01 12:36 UTC (permalink / raw)
To: ntg-context
[-- Attachment #1.1: Type: text/plain, Size: 432 bytes --]
On 2013–10–01 Marco Patzer wrote:
> Hi,
>
> I wonder if it's necessary to manually load the MetaPost variables
> using LoadPageState. Some of them are static and do not require an
> update on each page, e.g. NOfPages, but many of them might change on
> each page, e.g. OnOddPage, PageNumber, TextWidth.
@Hans: How about adding some more of the dynamic variables to the
MPinitializations in meta-ini.mkiv?
Marco
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Automatically loading the page state, LoadPageState
2013-10-01 12:15 Automatically loading the page state, LoadPageState Marco Patzer
2013-10-01 12:36 ` Marco Patzer
@ 2013-10-01 13:06 ` Hans Hagen
1 sibling, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2013-10-01 13:06 UTC (permalink / raw)
To: ntg-context
On 10/1/2013 2:15 PM, Marco Patzer wrote:
> Hi,
>
> I wonder if it's necessary to manually load the MetaPost variables
> using LoadPageState. Some of them are static and do not require an
> update on each page, e.g. NOfPages, but many of them might change on
> each page, e.g. OnOddPage, PageNumber, TextWidth. Forgetting to use
> LoadPageState easily results in perfectly valid code producing wrong
> results, which might not be hard to spot. Example:
sure, but a 'many' versus 'some' distinction is too fuzzy
> \setuplayout [width=10cm]
> \showframe
> \starttext
> \startMPcode
> fill unitsquare xyscaled (\the\textwidth, 2cm);
> \stopMPcode
>
> \startMPcode
> fill unitsquare xyscaled (TextWidth, 2cm);
> \stopMPcode
>
> \startMPcode
> LoadPageState;
> fill unitsquare xyscaled (TextWidth, 2cm);
> \stopMPcode
> \stoptext
>
> I assume it's too inefficient to load the page state automatically
> for each graphic. However, loading the page state automatically is
> simple:
Indeed. an option is to hook into setuplayout and signal changes but
this is never 'quick patch' code and I don't want to be bitten by it so
I need to test such hacks myself first (in real tests).
> \startMPinitializations
> LoadPageState;
> \stopMPinitializations
btw, normally I do
StartPage()
StopPage()
when I do something that relates to the page (and most of those runtime
graphics don't relate to the page at all)
so, more a "something i can look into" than "a quick hack"
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Automatically loading the page state, LoadPageState
2013-10-01 12:36 ` Marco Patzer
@ 2013-10-01 13:20 ` Hans Hagen
2013-10-01 18:35 ` Marco Patzer
0 siblings, 1 reply; 6+ messages in thread
From: Hans Hagen @ 2013-10-01 13:20 UTC (permalink / raw)
To: ntg-context
On 10/1/2013 2:36 PM, Marco Patzer wrote:
> On 2013–10–01 Marco Patzer wrote:
>
>> Hi,
>>
>> I wonder if it's necessary to manually load the MetaPost variables
>> using LoadPageState. Some of them are static and do not require an
>> update on each page, e.g. NOfPages, but many of them might change on
>> each page, e.g. OnOddPage, PageNumber, TextWidth.
>
> @Hans: How about adding some more of the dynamic variables to the
> MPinitializations in meta-ini.mkiv?
like what
anyway,
\starttext
\startMPcode \stopMPcode
\testfeatureonce{1}{\startMPcode for i=1 upto 1 : LoadPageState ;
endfor ; \stopMPcode}
\testfeatureonce{1}{\startMPcode for i=1 upto 10 : LoadPageState ;
endfor ; \stopMPcode}
\testfeatureonce{1}{\startMPcode for i=1 upto 100 : LoadPageState ;
endfor ; \stopMPcode}
\testfeatureonce{1}{\startMPcode for i=1 upto 1000 : LoadPageState ;
endfor ; \stopMPcode}
\testfeatureonce{1}{\startMPcode for i=1 upto 10000 : LoadPageState ;
endfor ; \stopMPcode}
% LoadPageState defined:
% system > starting feature test
% system > feature test done (0.001s)
% system > starting feature test
% system > feature test done (0.001s)
% system > starting feature test
% system > feature test done (0.002s)
% system > starting feature test
% system > feature test done (0.021s)
% system > starting feature test
% system > feature test done (0.210s)
% Directly set variables
% system > starting feature test
% system > feature test done (0.001s)
% system > starting feature test
% system > feature test done (0.001s)
% system > starting feature test
% system > feature test done (0.000s)
% system > starting feature test
% system > feature test done (0.001s)
% system > starting feature test
% system > feature test done (0.002s)
\stoptext
in mkiv the overhead is less than in mpii as we don't parse the blob in
the same way and the mpiv code is also more optimized so we can consider
dropping the SetPageState macro.
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Automatically loading the page state, LoadPageState
2013-10-01 13:20 ` Hans Hagen
@ 2013-10-01 18:35 ` Marco Patzer
2013-10-01 19:38 ` Hans Hagen
0 siblings, 1 reply; 6+ messages in thread
From: Marco Patzer @ 2013-10-01 18:35 UTC (permalink / raw)
To: ntg-context
[-- Attachment #1.1: Type: text/plain, Size: 417 bytes --]
On 2013–10–01 Hans Hagen wrote:
> in mkiv the overhead is less than in mpii as we don't parse the blob
> in the same way and the mpiv code is also more optimized so we can
> consider dropping the SetPageState macro.
I see you decided to drop LoadPageState. It's about 20ms overhead
per 1000 graphics, which is negligible, I'd say. Thanks for making
ConTeXt easier to use and more predictable.
Marco
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Automatically loading the page state, LoadPageState
2013-10-01 18:35 ` Marco Patzer
@ 2013-10-01 19:38 ` Hans Hagen
0 siblings, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2013-10-01 19:38 UTC (permalink / raw)
To: ntg-context
On 10/1/2013 8:35 PM, Marco Patzer wrote:
> On 2013–10–01 Hans Hagen wrote:
>
>> in mkiv the overhead is less than in mpii as we don't parse the blob
>> in the same way and the mpiv code is also more optimized so we can
>> consider dropping the SetPageState macro.
>
> I see you decided to drop LoadPageState. It's about 20ms overhead
> per 1000 graphics, which is negligible, I'd say. Thanks for making
> ConTeXt easier to use and more predictable.
well, it's an experimental patch so we'll see
(btw, it's less neglectable when you run context on a mobile phone -)
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-10-01 19:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-01 12:15 Automatically loading the page state, LoadPageState Marco Patzer
2013-10-01 12:36 ` Marco Patzer
2013-10-01 13:20 ` Hans Hagen
2013-10-01 18:35 ` Marco Patzer
2013-10-01 19:38 ` Hans Hagen
2013-10-01 13:06 ` Hans Hagen
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).