Mailing List Archive

EMBPERL: Calling Execute() multiple time per a page.
I have a loop that is calling Execute() to load a EMBPERL page as a
template. This template sets up and contains a bootstrap modal and some
javascript . The page I'm using as a test calls the template at least 500x.

This is really slowing down the loading of the page for the client.

Are there any suggestion for optimizing and / or speeding this up?

Thank You,
~Donavon
djlerman@yahoo.com


[$ while ( ($ID) = $sth->fetchrow) $]

[.- %opts = (); $opts{ID} = $ID; $opts{title} = "Modal Title";
$opts{footer} = "Modal Footer"; $opts{frameSrc} = "file.epl";
$opts{linkText} = 'Click Me to Open Modal';Execute("template.epl",
\%opts); -]

[$ endwhile $] *--- **template.epl* [- (%param) = %{$param[0]}; -] <!--
trigger modal --> <a id = "trigger_[+ $param{ID} +]" title = "[+
$param{title} +]" alt = "[+ $param{title} +]" style = "cursor:pointer;"
> [- $escmode = 0; -][+ $param{linkText} +][- $escmode = 1; -] </a>
<script> $('#trigger_[+ $param{ID} +]').click(function(){ var frameSrc =
"[- $escmode = 0; -][+ $param{frameSrc} +][- $escmode = 1; -]";
$('#iframe_[+ $param{ID} +]').attr("src",frameSrc); $('#modal_[+
$param{ID} +]').modal({show:true}) }); </script> <!-- modal --> <div
class="modal fade pageWidth" id="modal_[+ $param{ID} +]" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog
pageWidth" role="document"> <div class="modal-content"> <div
class="modal-header"> <button type="button" class="close"
data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">&times;</span></button> <h4 class="modal-title"
id="myModalLabel"> [+ $param{title} +] </h4> </div> <div
class="modal-body"> <iframe id="iframe_[+ $param{ID} +]" src=""
frameborder="0" height="400" class="pageFull"></iframe> </div> <div
class="modal-footer"> [+ $param{footer} +] <button type="button"
class="btn btn-default" data-dismiss="modal">Close</button> </div>
</div> </div> </div>
Re: EMBPERL: Calling Execute() multiple time per a page. [ In reply to ]
500 times - that's a lot!

Maybe you could run it once offline, and save the result as HTML?

Just an idea.

On Thu, Aug 25, 2016 at 10:35 PM, Donavon <donl@mycopanet.com> wrote:

> I have a loop that is calling Execute() to load a EMBPERL page as a
> template. This template sets up and contains a bootstrap modal and some
> javascript . The page I'm using as a test calls the template at least 500x.
>
> This is really slowing down the loading of the page for the client.
>
> Are there any suggestion for optimizing and / or speeding this up?
>
> Thank You,
> ~Donavon
> djlerman@yahoo.com
>
>
> [$ while ( ($ID) = $sth->fetchrow) $]
>
> [.-
> %opts = (); $opts{ID} = $ID;
> $opts{title} = "Modal Title";
> $opts{footer} = "Modal Footer";
> $opts{frameSrc} = "file.epl";
> $opts{linkText} = 'Click Me to Open Modal';
> Execute("template.epl", \%opts);
> -]
>
> [$ endwhile $]
>
>
> *--- **template.epl*
>
> [-
> (%param) = %{$param[0]};
> -]
> <!-- trigger modal -->
> <a id = "trigger_[+ $param{ID} +]"
> title = "[+ $param{title} +]"
> alt = "[+ $param{title} +]"
> style = "cursor:pointer;"
> >
> [- $escmode = 0; -][+ $param{linkText} +][- $escmode = 1; -]
> </a>
> <script>
>
>
> $('#trigger_[+ $param{ID} +]').click(function(){
> var frameSrc = "[- $escmode = 0; -][+ $param{frameSrc} +][- $escmode = 1; -]";
>
> $('#iframe_[+ $param{ID} +]').attr("src",frameSrc);
>
> $('#modal_[+ $param{ID} +]').modal({show:true})
> });
>
> </script>
>
>
> <!-- modal -->
> <div class="modal fade pageWidth" id="modal_[+ $param{ID} +]" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
> <div class="modal-dialog pageWidth" role="document">
> <div class="modal-content">
> <div class="modal-header">
> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
> <h4 class="modal-title" id="myModalLabel">
> [+ $param{title} +]
> </h4>
> </div>
> <div class="modal-body">
> <iframe id="iframe_[+ $param{ID} +]" src="" frameborder="0" height="400" class="pageFull"></iframe>
> </div>
> <div class="modal-footer">
> [+ $param{footer} +] <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
> </div>
> </div>
> </div>
> </div>
>
>
>
>
Re: EMBPERL: Calling Execute() multiple time per a page. [ In reply to ]
What you have is a slow version of an Embperl subroutine. Use an actual
Embperl subroutine instead. Use Execute at most once to load it.

It's my understanding that generally, templates are done in
Embperl::Object. But when doing it that way, your template is stored in
your base Embperl::Object file, as Embperl code, rather than having
everything stored in a database. Of course, that has the advantage that
you don't need to pull 500+ rows from your database to generate your page.

--
Ed Grimm



From: Donavon <donl@mycopanet.com>
To: "embperl@perl.apache.org" <embperl@perl.apache.org>
Date: 08/25/2016 05:35 PM
Subject: EMBPERL: Calling Execute() multiple time per a page.



I have a loop that is calling Execute() to load a EMBPERL page as a
template. This template sets up and contains a bootstrap modal and some
javascript . The page I'm using as a test calls the template at least
500x.
This is really slowing down the loading of the page for the client.
Are there any suggestion for optimizing and / or speeding this up?
Thank You,
~Donavon
djlerman@yahoo.com



[$ while ( ($ID) = $sth->fetchrow) $]

[.-
%opts = ();
$opts{ID} = $ID;
$opts{title} = "Modal Title";
$opts{footer} = "Modal Footer";
$opts{frameSrc} = "file.epl";
$opts{linkText} = 'Click Me to Open Modal';
Execute("template.epl", \%opts);
-]

[$ endwhile $]



--- template.epl

[-
(%param) = %{$param[0]};
-]
<!-- trigger modal -->
<a id = "trigger_[+ $param{ID} +]"
title = "[+ $param{title} +]"
alt = "[+ $param{title} +]"
style = "cursor:pointer;"
>
[- $escmode = 0; -][+ $param{linkText} +][- $escmode = 1; -]
</a>
<script>


$('#trigger_[+ $param{ID} +]').click(function(){
var frameSrc = "[- $escmode = 0; -][+ $param{frameSrc} +][- $escmode =
1; -]";

$('#iframe_[+ $param{ID} +]').attr("src",frameSrc);

$('#modal_[+ $param{ID} +]').modal({show:true})
});

</script>


<!-- modal -->
<div class="modal fade pageWidth" id="modal_[+ $param{ID} +]"
tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog pageWidth" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">
[+ $param{title} +]
</h4>
</div>
<div class="modal-body">
<iframe id="iframe_[+ $param{ID} +]" src="" frameborder="0"
height="400" class="pageFull"></iframe>
</div>
<div class="modal-footer">
[+ $param{footer} +] <button type="button" class="btn btn-default"
data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Re: EMBPERL: Calling Execute() multiple time per a page. [ In reply to ]
I modified it to use [$sub$]
<https://perl.apache.org/embperl/pod/doc/Embperl.-page-3-.htm#sect_7>
and [+ local $escmode = 0; $something +]

I get the following error:

ERR: 24: Error in Perl code: Undefined subroutine
&Embperl::__82::subroutinecalled at ...



*--- main.epl*

[- Execute("subroutine.epl"); -]

[$ while ( ($ID) = $sth->fetchrow) $] [.- %opts = ();
$opts{ID} = $ID; $opts{title} = "Modal Title";
$opts{footer} = "Modal Footer"; $opts{frameSrc} =
"file.epl"; $opts{linkText} = 'Click Me to Open Modal';

subroutine(\%opts); -] [$ endwhile $]

*--- subroutine.epl*

[$ sub subroutine $] [- (%param) = %{$param[0]}; -]

<!-- trigger modal -->

<a id = "trigger_[+ $param{ID} +]" title = "[+
$param{title} +]" alt = "[+ $param{title} +]"
style = "cursor:pointer;" > [+ local $escmode = 0;
$param{linkText} +] </a>

<script> $('#trigger_[+ $param{ID} +]').click(function(){
var frameSrc = "[+ local $escmode = 0; $param{frameSrc} +]";
$('#iframe_[+ $param{ID} +]').attr("src",frameSrc); $('#modal_[+
$param{ID} +]').modal({show:true}) }); </script>

<!-- modal -->

<div class="modal fade pageWidth" id="modal_[+ $param{ID} +]"
tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div
class="modal-dialog pageWidth" role="document"> <div
class="modal-content"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel"> [+
$param{title} +] </h4> </div> <div
class="modal-body"> <iframe id="iframe_[+ $param{ID} +]"
src="" frameborder="0" height="400" class="pageFull"></iframe>
</div> <div class="modal-footer"> [+ $param{footer} +]
<button type="button" class="btn btn-default"
data-dismiss="modal">Close</button> </div> </div>
</div> </div> [$ endsub $]


On 8/25/2016 6:02 PM, Angus Lees wrote:
> On Fri, 26 Aug 2016 at 08:37 Ed Grimm <eg@raytheon.com
> <mailto:eg@raytheon.com>> wrote:
>
> What you have is a slow version of an Embperl subroutine. Use an
> actual Embperl subroutine instead. Use Execute at most once to
> load it.
>
>
> ^ This. It's been a decade or two since I last wrote any Embperl
> code, but I'm guessing you're being slowed down by Embperl having to
> find and stat the 'template.epl' file to see if it has changed 500 times.
>
> Wrap your template code in a [$sub$], Execute template.epl once at the
> top somewhere (one file stat()) and import the new [$sub$] function,
> then just call the sub like a regular perl function (no additional
> stat() lookup) inside your loop. See the docs for [$sub$]
> <https://perl.apache.org/embperl/pod/doc/Embperl.-page-3-.htm#sect_7>
>
>
> As an aside, this construct:
> [- $escmode = 0 -][+ $something +][- $escmode = 1 -]
> Is much safer if written as the following, since you can't forget to
> restore $escmode:
> [+ local $escmode = 0; $something +]
>
> - Gus
>
> It's my understanding that generally, templates are done in
> Embperl::Object. But when doing it that way, your template is
> stored in your base Embperl::Object file, as Embperl code, rather
> than having everything stored in a database. Of course, that has
> the advantage that you don't need to pull 500+ rows from your
> database to generate your page.
>
> --
> Ed Grimm
>
>
>
> From: Donavon <donl@mycopanet.com <mailto:donl@mycopanet.com>>
> To: "embperl@perl.apache.org <mailto:embperl@perl.apache.org>"
> <embperl@perl.apache.org <mailto:embperl@perl.apache.org>>
> Date: 08/25/2016 05:35 PM
> Subject: EMBPERL: Calling Execute() multiple time per a page.
> ------------------------------------------------------------------------
>
>
>
> I have a loop that is calling Execute() to load a EMBPERL page as
> a template. This template sets up and contains a bootstrap modal
> and some javascript . The page I'm using as a test calls the
> template at least 500x.
>
> This is really slowing down the loading of the page for the client.
>
> Are there any suggestion for optimizing and / or speeding this up?
>
> Thank You,
> ~Donavon_
> __djlerman@yahoo.com_ <mailto:djlerman@yahoo.com>
>
>
>
> [$ while ( ($ID) = $sth->fetchrow) $]
>
> [.-
> %opts = ();
> $opts{ID} = $ID;
> $opts{title} = "Modal Title";
> $opts{footer} = "Modal Footer";
> $opts{frameSrc} = "file.epl";
> $opts{linkText} = 'Click Me to Open Modal';
> Execute("template.epl", \%opts);
> -]
>
> [$ endwhile $]
>
>
>
> *--- template.epl*
>
> [-
> (%param) = %{$param[0]};
> -]
> <!-- trigger modal -->
> <a id = "trigger_[+ $param{ID} +]"
> title = "[+ $param{title} +]"
> alt = "[+ $param{title} +]"
> style = "cursor:pointer;"
> >
> [- $escmode = 0; -][+ $param{linkText} +][- $escmode = 1; -]
> </a>
> <script>
>
>
> $('#trigger_[+ $param{ID} +]').click(function(){
> var frameSrc = "[- $escmode = 0; -][+ $param{frameSrc} +][-
> $escmode = 1; -]";
>
> $('#iframe_[+ $param{ID} +]').attr("src",frameSrc);
>
> $('#modal_[+ $param{ID} +]').modal({show:true})
> });
>
> </script>
>
>
> <!-- modal -->
> <div class="modal fade pageWidth" id="modal_[+ $param{ID} +]"
> tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
> <div class="modal-dialog pageWidth" role="document">
> <div class="modal-content">
> <div class="modal-header">
> <button type="button" class="close" data-dismiss="modal"
> aria-label="Close"><span aria-hidden="true">&times;</span></button>
> <h4 class="modal-title" id="myModalLabel">
> [+ $param{title} +]
> </h4>
> </div>
> <div class="modal-body">
> <iframe id="iframe_[+ $param{ID} +]" src="" frameborder="0"
> height="400" class="pageFull"></iframe>
> </div>
> <div class="modal-footer">
> [+ $param{footer} +] <button type="button" class="btn
> btn-default" data-dismiss="modal">Close</button>
> </div>
> </div>
> </div>
> </div>
>
>
>
>
> Message protected by MailGuard: e-mail anti-virus, anti-spam and
> content filtering.
> http://www.mailguard.com.au/mg
>
>
> Report this message as spam
> <https://console.mailguard.com.au/ras/1P7uDVpwwI/zbZIfBnhOSGGC3Q2arnxH/0.612>
>
>
Re: EMBPERL: Calling Execute() multiple time per a page. [ In reply to ]
On 08/25/2016 06:36 PM, Ed Grimm wrote:
> What you have is a slow version of an Embperl subroutine. Use an actual
> Embperl subroutine instead. Use Execute at most once to load it.
>
> It's my understanding that generally, templates are done in
> Embperl::Object. But when doing it that way, your template is stored in
> your base Embperl::Object file, as Embperl code, rather than having
> everything stored in a database. Of course, that has the advantage that
> you don't need to pull 500+ rows from your database to generate your page.
>

nice. I thought I was the lone user of embperl at this point


--
So many immigrant groups have swept through our town
that Brooklyn, like Atlantis, reaches mythological
proportions in the mind of the world - RI Safir 1998
http://www.mrbrklyn.com

DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
http://www.nylxs.com - Leadership Development in Free Software
http://www2.mrbrklyn.com/resources - Unpublished Archive
http://www.coinhangout.com - coins!
http://www.brooklyn-living.com

Being so tracked is for FARM ANIMALS and and extermination camps,
but incompatible with living as a free human being. -RI Safir 2013

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: EMBPERL: Calling Execute() multiple time per a page. [ In reply to ]
Ruben Safir wrote:
> nice. I thought I was the lone user of embperl at this point

I'm still here! My website is the largest bicycle touring journal site
in the world, running on Embperl since 2000. I'm sad that it's not what
all the cool kids use any more.

http://www.crazyguyonabike.com/

I don't participate much in the list, mostly because the people who do
contribute seem to know much much more about Perl than I ever will. :P

Neil

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org