create new tag
, view all tags

Refactoring Proposal: Eliminate TWiki's homegrown benchmark module Monitor.pm


TWiki's homegrown Monitor.pm isn't too well documented and doesn't provide nice results. Better methods are readily available, and there's no reasonable chance to add all their features to Monitor.pm.


The module Monitor.pm and all references to it (including the environment variable TWIKI_MONITOR) can be eliminated from the code. In all cases where the monitor can be used, CPAN:Devel::NYTProf provides better results.

  • From the command line: Instead of TWIKI_MONITOR=2 view Main.WebHome, you use perl -T -d:NYTProf view Main.WebHome.
  • From CliRunnerContrib: Set $runner->perlOptions('-T -dNYTProf').
  • From Apache, there's a module CPAN:Devel::NYTProf::Apache - I haven't figured out how to do this with TWiki's Monitor at all.
  • Devel::NYTProf can also be used in a pure-perl webserver so that you can collect multiple requests in one measurement - I plan to extend the PSGI contrib to make that readily available.

Devel:NYTProf doesn't need any instrumentation in the code. The only downside is that it creates lots of output (ca. 1MB for one view call from the commandline, and 28MB for the comprehensive, line-by-line, HTML output).

-- HaraldJoerg - 2018-01-31

Impact and Available Solutions

WhatDoesItAffect: Performance
HaveQuickFixFor: Refactorings shouldn't be done as a quick fix


In the documentation, the description of TWiki's Monitor can be replaced by a short introduction to Devel::NYTProf, with pointers to the extensive documentation and guidelines in the web.


There are a couple of places which refer to the environment variable TWIKI_MONITOR or call Monitor::MARK, these can be eliminated. The module itself would no longer be necessary.

The performance imrovement on "normal" TWiki operations (i.e. when no monitoring takes placs) is just measurable: about 0.1%, according to Devel::NYTProf.


Accepted by KampalaReleaseMeeting2018x02x01.

-- Peter Thoeny - 2018-02-01

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2018-02-01 - PeterThoeny
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.