SlideShare una empresa de Scribd logo
1 de 14
Descargar para leer sin conexión
Óñêîðåíèå îáðàáîòêè øàáëîíîâ

        Template-Toolkit
  Èëè êýøèðîâàíèå ïîäøàáëîíîâ â TT

        Âàëåðèé Ñòóäåííèêîâ,
            despair@reg.ru


             Èþíü 2010
             YAPC 2010
Òÿæ¼ëûé ñàéò...
Òîðìîçèò...




Çàïðîñû îáðàáàòûâàþòñÿ ìåäëåííî...

Document Length:       121170 bytes

Concurrency Level:     1
...
Requests per second:   6.55 [#/sec] (mean)
Time per request:      152.677 [ms] (mean)
Ðàçáèðàåìñÿ â ïðè÷èíàõ...

[debug] Rendering template "index.html"
[info] Request took 0.155370s (6.436/s)
.--------------------------------------+-----------.
| Action                                | Time      |
+--------------------------------------+-----------+
| -> /_DISPATCH                         | 0.138753s |
| -> /_BEGIN                           | 0.005263s |
| /begin                                | 0.004580s |
| -> /_AUTO                             | 0.000968s |
| /auto                                | 0.000270s |
| -> /_ACTION                           | 0.000883s |
| /index                                | 0.000363s |
| -> /_END                             | 0.129827s |
| /end                                  | 0.129265s |
|    -> FrontOffice::View::TT->process | 0.128254s |
'--------------------------------------+-----------'
Êàê äåòàëèçîâàòü ïî ïîäøàáëîíàì?

        Íàì ïîìîæåò ñòàòüÿ ¾Proling in Template Toolkit
        via overriding¿ by Randal L. Schwartz
package My::Template::Context;                                }
use base qw(Template::Context);                           }
                                                          $totals{$template}[5] ++;     # count of calls
my @stack;
my %totals;                                                unless (@stack) {
                                                               ## top level again, time to display results
sub process {                                                  print STDERR -- $template at . localtime, :n
    my $self = shift;                                          printf STDERR %3s %3s %6s %6s %6s %6s %sn,
                                                                 qw(cnt clk user sys cuser csys template);
    my $template = $_[0];                                      for my $template (sort keys %totals) {
    if (UNIVERSAL::isa($template, Template::Document)) {       my @values = @{$totals{$template}};
$template = $template-name || $template;                        printf STDERR %3d %3d %6.2f %6.2f %6.2f %6.2f
    }                                                              $values[5], @values[0..4], $template;
                                                      }
    push @stack, [time, times];                       print STDERR -- endn;
                                                      %totals = ();                # clear out results
    my @return = wantarray ?                               }
$self-SUPER::process(@_) :
scalar $self-SUPER::process(@_);                          # return value from process:
                                                           wantarray ? @return : $return[0];
    my @delta_times = @{pop @stack};                  }
    @delta_times = map { $_ - shift @delta_times } time, times;
    for (0..$#delta_times) {                          $Template::Config::CONTEXT = __PACKAGE__;
        $totals{$template}[$_] += $delta_times[$_];
        for my $parent (@stack) {                     1;
          $parent-[$_] += $delta_times[$_] if @stack; # parent adjust
Ïðîôàéëèíã ïîäøàáëîíîâ

-- index.html at Thu Jun 10 18:20:56 2010:
cnt clk user      sys cuser csys template
1 0.0056 0.0000 0 0 0 common/footer_common.inc
1 0.0006 0.0000 0 0 0 common/header_topline.inc
1 0.0006 0.0000 0 0 0 footer.inc
1 0.0004 0.0000 0 0 0 footer_screen.inc
1 0.0010 0.0000 0 0 0 header.inc
1 0.0010 0.0000 0 0 0 header_screen.inc
1 0.0187 0.0200 0 0 0 header_screen_body_cached.inc
1 0.0005 0.0000 0 0 0 header_screen_head_cached.inc
1 0.0015 0.0000 0 0 0 index.html
1 0.0036 0.0000 0 0 0 index_body.inc
1 0.0145 0.0200 0 0 0 index_promo_bar.inc
1 0.0775 0.0800 0 0 0 print/zones.inc
1 0.0004 0.0000 0 0 0 tabs.inc
Ìîäóëü äëÿ êýøèðîâàíèÿ




use Template : : C o n t e x t : : C a c h e a b l e ;

Template : : C o n t e x t : : C a c h e a b l e : : c o n f i g u r e _ c a c h i n g (
   SRS : : Cache : : Memcached : : get ,
   SRS : : Cache : : Memcached : : put ,
);

$Template : : C o n t e x t : : C a c h e a b l e : : DEBUG = 1 ;
Êàê ýòî âûãëÿäèò â øàáëîíàõ




index.html:
[% PROCESS index_reg_bar.inc
    lang = lang
    pricegroup = pricegroup
    __cache_time = -1
%]
Êàê ýòî âûãëÿäèò â øàáëîíàõ

header_screen.inc:
[%- PROCESS
  header_screen_body_cached.inc
    ...
    __nocache_banner_no = banner_no
    __nocache_lang = lang
    __nocache_wide_flag = wide_flag
    __nocache_path_query = path_query
    __nocache_user_id = user_id
    __nocache_user_balance = user_balance
    ...
    __nocache_req_method = c.req.method
    __cache_time = user_messages.size() ? 0 : -1
-%]
Âðóáàåì êýøèðîâàíèå...




-- index.html at Thu Jun 10 18:52:04 2010:
    cnt clk   user    sys cuser csys template
  1 0.0002 0 0 0 0 footer.inc CACHED
  1 0.0010 0 0 0 0 header.inc
  1 0.0005 0 0 0 0 header_screen.inc CACHED
  1 0.0015 0 0 0 0 index.html
  1 0.0002 0 0 0 0 index_body.inc CACHED
  1 0.0003 0 0 0 0 index_promo_bar.inc CACHED
  1 0.0004 0 0 0 0 print/zones.inc CACHED
-- end
Âðóáàåì êýøèðîâàíèå...

[debug] Rendering template index.html
[info] Request took 0.029016s (34.464/s)
.-------------------------------------+-----------.
| Action                              | Time      |
+-------------------------------------+-----------+
| - /_DISPATCH                       | 0.014121s |
| - /_BEGIN                          | 0.002807s |
| /begin                              | 0.002152s |
| - /_AUTO                           | 0.000860s |
| /auto                               | 0.000276s |
| - /_ACTION                         | 0.000884s |
| /index                              | 0.000370s |
| - /_END                            | 0.007854s |
| /end                                | 0.007279s |
|    - FrontOffice::View::TT-process| 0.006267s |
'-------------------------------------+-----------'
Ðåçóëüòàò...


Server Hostname:        www1.reg.ru
Server Port:            80

Document Path:          /
Document Length:        121176 bytes

Concurrency Level:      1
Time taken for tests:   9.524 seconds
Total transferred:      36445800 bytes
HTML transferred:       36352800 bytes
Requests per second:    31.50 [#/sec] (mean)
Time per request:       31.746 [ms] (mean)
Transfer rate:          3737.15 [Kbytes/sec] received
Ðåçóëüòàò...




    Óìåíüøèëè îáùåå âðåìÿ îáðàáîòêè çàïðîñà â 4.9
    ðàçà;
    Óñêîðèëè îáðàáîòêó øàáëîíà â 20 ðàç;
Ñïàñèáî!




Ìîäóëü Template::Context::Cacheable ëåæèò òóò
https://svn.reg.ru/oss/Template-Context-Cacheable/

Más contenido relacionado

La actualidad más candente

Drush. Secrets come out.
Drush. Secrets come out.Drush. Secrets come out.
Drush. Secrets come out.Alex S
 
Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)brian d foy
 
全裸でワンライナー(仮)
全裸でワンライナー(仮)全裸でワンライナー(仮)
全裸でワンライナー(仮)Yoshihiro Sugi
 
Things I Believe Now That I'm Old
Things I Believe Now That I'm OldThings I Believe Now That I'm Old
Things I Believe Now That I'm OldRoss Tuck
 
Gta v savegame
Gta v savegameGta v savegame
Gta v savegamehozayfa999
 
Profiling and monitoring ruby & rails applications
Profiling and monitoring ruby & rails applicationsProfiling and monitoring ruby & rails applications
Profiling and monitoring ruby & rails applicationsJano Suchal
 
Command Bus To Awesome Town
Command Bus To Awesome TownCommand Bus To Awesome Town
Command Bus To Awesome TownRoss Tuck
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giantsIan Barber
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionIan Barber
 
Teaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersTeaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersIan Barber
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with PuppetPuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with PuppetOlinData
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with PuppetPuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with PuppetWalter Heck
 
Models and Service Layers, Hemoglobin and Hobgoblins
Models and Service Layers, Hemoglobin and HobgoblinsModels and Service Layers, Hemoglobin and Hobgoblins
Models and Service Layers, Hemoglobin and HobgoblinsRoss Tuck
 
Learning Perl 6
Learning Perl 6 Learning Perl 6
Learning Perl 6 brian d foy
 
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress WordCamp Kyiv
 
WordPress Cuztom Helper
WordPress Cuztom HelperWordPress Cuztom Helper
WordPress Cuztom Helperslicejack
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous phpWim Godden
 

La actualidad más candente (20)

Drush. Secrets come out.
Drush. Secrets come out.Drush. Secrets come out.
Drush. Secrets come out.
 
Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)
 
全裸でワンライナー(仮)
全裸でワンライナー(仮)全裸でワンライナー(仮)
全裸でワンライナー(仮)
 
Things I Believe Now That I'm Old
Things I Believe Now That I'm OldThings I Believe Now That I'm Old
Things I Believe Now That I'm Old
 
Gta v savegame
Gta v savegameGta v savegame
Gta v savegame
 
Profiling and monitoring ruby & rails applications
Profiling and monitoring ruby & rails applicationsProfiling and monitoring ruby & rails applications
Profiling and monitoring ruby & rails applications
 
Command Bus To Awesome Town
Command Bus To Awesome TownCommand Bus To Awesome Town
Command Bus To Awesome Town
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giants
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 Version
 
Teaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersTeaching Your Machine To Find Fraudsters
Teaching Your Machine To Find Fraudsters
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with PuppetPuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with PuppetPuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
 
Models and Service Layers, Hemoglobin and Hobgoblins
Models and Service Layers, Hemoglobin and HobgoblinsModels and Service Layers, Hemoglobin and Hobgoblins
Models and Service Layers, Hemoglobin and Hobgoblins
 
Learning Perl 6
Learning Perl 6 Learning Perl 6
Learning Perl 6
 
Nubilus Perl
Nubilus PerlNubilus Perl
Nubilus Perl
 
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
 
Perl Web Client
Perl Web ClientPerl Web Client
Perl Web Client
 
WordPress Cuztom Helper
WordPress Cuztom HelperWordPress Cuztom Helper
WordPress Cuztom Helper
 
Php 101: PDO
Php 101: PDOPhp 101: PDO
Php 101: PDO
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous php
 

Similar a Tt subtemplates-caching

Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From IusethisMarcus Ramberg
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworksdiego_k
 
Curscatalyst
CurscatalystCurscatalyst
CurscatalystKar Juan
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Shinya Ohyanagi
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak PROIDEA
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuningAOE
 
I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfpnaran46
 
How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...doughellmann
 
Idoc script beginner guide
Idoc script beginner guide Idoc script beginner guide
Idoc script beginner guide Vinay Kumar
 
Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»e-Legion
 
Monitoring with Prometheus
Monitoring with PrometheusMonitoring with Prometheus
Monitoring with PrometheusShiao-An Yuan
 
MongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineMongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineJason Terpko
 
Assignment no39
Assignment no39Assignment no39
Assignment no39Jay Patel
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ EtsyNishan Subedi
 
2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pagessparkfabrik
 

Similar a Tt subtemplates-caching (20)

Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From Iusethis
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
Curscatalyst
CurscatalystCurscatalyst
Curscatalyst
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
 
Memory Manglement in Raku
Memory Manglement in RakuMemory Manglement in Raku
Memory Manglement in Raku
 
Symfony 1, mi viejo amigo
Symfony 1, mi viejo amigoSymfony 1, mi viejo amigo
Symfony 1, mi viejo amigo
 
I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdf
 
How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...
 
Test upload
Test uploadTest upload
Test upload
 
Idoc script beginner guide
Idoc script beginner guide Idoc script beginner guide
Idoc script beginner guide
 
Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»
 
AngularJS and SPA
AngularJS and SPAAngularJS and SPA
AngularJS and SPA
 
Monitoring with Prometheus
Monitoring with PrometheusMonitoring with Prometheus
Monitoring with Prometheus
 
MongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineMongoDB - Aggregation Pipeline
MongoDB - Aggregation Pipeline
 
Assignment no39
Assignment no39Assignment no39
Assignment no39
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ Etsy
 
2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages
 

Último

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Último (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Tt subtemplates-caching

  • 1. Óñêîðåíèå îáðàáîòêè øàáëîíîâ Template-Toolkit Èëè êýøèðîâàíèå ïîäøàáëîíîâ â TT Âàëåðèé Ñòóäåííèêîâ, despair@reg.ru Èþíü 2010 YAPC 2010
  • 3. Òîðìîçèò... Çàïðîñû îáðàáàòûâàþòñÿ ìåäëåííî... Document Length: 121170 bytes Concurrency Level: 1 ... Requests per second: 6.55 [#/sec] (mean) Time per request: 152.677 [ms] (mean)
  • 4. Ðàçáèðàåìñÿ â ïðè÷èíàõ... [debug] Rendering template "index.html" [info] Request took 0.155370s (6.436/s) .--------------------------------------+-----------. | Action | Time | +--------------------------------------+-----------+ | -> /_DISPATCH | 0.138753s | | -> /_BEGIN | 0.005263s | | /begin | 0.004580s | | -> /_AUTO | 0.000968s | | /auto | 0.000270s | | -> /_ACTION | 0.000883s | | /index | 0.000363s | | -> /_END | 0.129827s | | /end | 0.129265s | | -> FrontOffice::View::TT->process | 0.128254s | '--------------------------------------+-----------'
  • 5. Êàê äåòàëèçîâàòü ïî ïîäøàáëîíàì? Íàì ïîìîæåò ñòàòüÿ ¾Proling in Template Toolkit via overriding¿ by Randal L. Schwartz package My::Template::Context; } use base qw(Template::Context); } $totals{$template}[5] ++; # count of calls my @stack; my %totals; unless (@stack) { ## top level again, time to display results sub process { print STDERR -- $template at . localtime, :n my $self = shift; printf STDERR %3s %3s %6s %6s %6s %6s %sn, qw(cnt clk user sys cuser csys template); my $template = $_[0]; for my $template (sort keys %totals) { if (UNIVERSAL::isa($template, Template::Document)) { my @values = @{$totals{$template}}; $template = $template-name || $template; printf STDERR %3d %3d %6.2f %6.2f %6.2f %6.2f } $values[5], @values[0..4], $template; } push @stack, [time, times]; print STDERR -- endn; %totals = (); # clear out results my @return = wantarray ? } $self-SUPER::process(@_) : scalar $self-SUPER::process(@_); # return value from process: wantarray ? @return : $return[0]; my @delta_times = @{pop @stack}; } @delta_times = map { $_ - shift @delta_times } time, times; for (0..$#delta_times) { $Template::Config::CONTEXT = __PACKAGE__; $totals{$template}[$_] += $delta_times[$_]; for my $parent (@stack) { 1; $parent-[$_] += $delta_times[$_] if @stack; # parent adjust
  • 6. Ïðîôàéëèíã ïîäøàáëîíîâ -- index.html at Thu Jun 10 18:20:56 2010: cnt clk user sys cuser csys template 1 0.0056 0.0000 0 0 0 common/footer_common.inc 1 0.0006 0.0000 0 0 0 common/header_topline.inc 1 0.0006 0.0000 0 0 0 footer.inc 1 0.0004 0.0000 0 0 0 footer_screen.inc 1 0.0010 0.0000 0 0 0 header.inc 1 0.0010 0.0000 0 0 0 header_screen.inc 1 0.0187 0.0200 0 0 0 header_screen_body_cached.inc 1 0.0005 0.0000 0 0 0 header_screen_head_cached.inc 1 0.0015 0.0000 0 0 0 index.html 1 0.0036 0.0000 0 0 0 index_body.inc 1 0.0145 0.0200 0 0 0 index_promo_bar.inc 1 0.0775 0.0800 0 0 0 print/zones.inc 1 0.0004 0.0000 0 0 0 tabs.inc
  • 7. Ìîäóëü äëÿ êýøèðîâàíèÿ use Template : : C o n t e x t : : C a c h e a b l e ; Template : : C o n t e x t : : C a c h e a b l e : : c o n f i g u r e _ c a c h i n g ( SRS : : Cache : : Memcached : : get , SRS : : Cache : : Memcached : : put , ); $Template : : C o n t e x t : : C a c h e a b l e : : DEBUG = 1 ;
  • 8. Êàê ýòî âûãëÿäèò â øàáëîíàõ index.html: [% PROCESS index_reg_bar.inc lang = lang pricegroup = pricegroup __cache_time = -1 %]
  • 9. Êàê ýòî âûãëÿäèò â øàáëîíàõ header_screen.inc: [%- PROCESS header_screen_body_cached.inc ... __nocache_banner_no = banner_no __nocache_lang = lang __nocache_wide_flag = wide_flag __nocache_path_query = path_query __nocache_user_id = user_id __nocache_user_balance = user_balance ... __nocache_req_method = c.req.method __cache_time = user_messages.size() ? 0 : -1 -%]
  • 10. Âðóáàåì êýøèðîâàíèå... -- index.html at Thu Jun 10 18:52:04 2010: cnt clk user sys cuser csys template 1 0.0002 0 0 0 0 footer.inc CACHED 1 0.0010 0 0 0 0 header.inc 1 0.0005 0 0 0 0 header_screen.inc CACHED 1 0.0015 0 0 0 0 index.html 1 0.0002 0 0 0 0 index_body.inc CACHED 1 0.0003 0 0 0 0 index_promo_bar.inc CACHED 1 0.0004 0 0 0 0 print/zones.inc CACHED -- end
  • 11. Âðóáàåì êýøèðîâàíèå... [debug] Rendering template index.html [info] Request took 0.029016s (34.464/s) .-------------------------------------+-----------. | Action | Time | +-------------------------------------+-----------+ | - /_DISPATCH | 0.014121s | | - /_BEGIN | 0.002807s | | /begin | 0.002152s | | - /_AUTO | 0.000860s | | /auto | 0.000276s | | - /_ACTION | 0.000884s | | /index | 0.000370s | | - /_END | 0.007854s | | /end | 0.007279s | | - FrontOffice::View::TT-process| 0.006267s | '-------------------------------------+-----------'
  • 12. Ðåçóëüòàò... Server Hostname: www1.reg.ru Server Port: 80 Document Path: / Document Length: 121176 bytes Concurrency Level: 1 Time taken for tests: 9.524 seconds Total transferred: 36445800 bytes HTML transferred: 36352800 bytes Requests per second: 31.50 [#/sec] (mean) Time per request: 31.746 [ms] (mean) Transfer rate: 3737.15 [Kbytes/sec] received
  • 13. Ðåçóëüòàò... Óìåíüøèëè îáùåå âðåìÿ îáðàáîòêè çàïðîñà â 4.9 ðàçà; Óñêîðèëè îáðàáîòêó øàáëîíà â 20 ðàç;
  • 14. Ñïàñèáî! Ìîäóëü Template::Context::Cacheable ëåæèò òóò https://svn.reg.ru/oss/Template-Context-Cacheable/