From aa02f21e869c9e81445f79e10893f377529961c6 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 14 Jun 2017 15:07:04 +0000 Subject: [PATCH] Measure time for processing each steps | wip #1475 @0.75 --- inc/ws/Controlleur/class.ws.ajax.php | 2 +- .../html5/master/class.ws.html5.compiler.php | 33 ++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php index cf79efd89..2aaff30a9 100644 --- a/inc/ws/Controlleur/class.ws.ajax.php +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -231,7 +231,7 @@ class wsAjax extends cubeAjax { if (!$_FILES[$t]['error']) { $ext = CubeIT_Files::getExtension($_FILES[$t]['name']); - //move_uploaded_file($_FILES[$t]['tmp_name'], $wdir . '/' . $t . '.' . $ext); + move_uploaded_file($_FILES[$t]['tmp_name'], $wdir . '/' . $t . '.' . $ext); $save['theme'][$t] = $t . '.' . $ext; if ($t == 'filesalt') { diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index c4c75180a..0533bf4f5 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -157,11 +157,14 @@ class wsHTML5Compiler { protected $multiApp = false; protected $pageLabels = array(); protected $stylesheets = array(); + protected $logfp = null; + protected $logtime = null; function __construct($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false) { global $core; + $this->phonegapVersion = wsHTML5::getPhonegapVersion($phonegapVersion); $this->appcache = $appcache; $this->multiApp = $this->home = $home; @@ -187,6 +190,7 @@ class wsHTML5Compiler { return; } $this->book_id = $book_id; + $this->log('Start compilation'); if (is_null($dir)) { $this->dir = WS_BOOKS . '/html5/' . $book_id . '/'; @@ -201,6 +205,7 @@ class wsHTML5Compiler { if (!file_exists($this->dir)) { mkdir($this->dir, 0777, true); } + $this->log('Clean vdir'); $this->daoBook = new wsDAOBook($core->con); $this->book = $this->daoBook->selectById($book_id); @@ -247,6 +252,20 @@ class wsHTML5Compiler { $this->config = cubeObject::merge($this->book->parametres->toStandardObject(), $this->theme->parametres->toStandardObject()); } + public function log($step) { + $currenttime = microtime(true); + if (null === $this->logfp) { + $this->logfp = fopen('/var/log/extranet/htmlconversions/' . $this->book_id . '.log', 'w+'); + } + if (null === $this->logtime) { + $this->logtime = $currenttime; + } + $time = $currenttime - $this->logtime; + $log = $step . ' | ' . round($time, 3) . 's' . "\n"; + fwrite($this->logfp, $log); + $this->logtime = $currenttime; + } + public function addPageLabel($page, $label) { $this->pageLabels[$label] = $page; } @@ -276,6 +295,8 @@ class wsHTML5Compiler { public function compile() { + $this->log('Start compile process'); + $dirsToCreate = array('data/images', 'data/contents', 'data/background', 'data/thumbnails', 'data/style'); if (in_array('flv', $this->getVideosFormats())) { $dirsToCreate[] = 'swf'; @@ -310,17 +331,27 @@ class wsHTML5Compiler { if (file_exists($this->vdir . '/swf')) { $this->copy($this->assets . '/swf/video.swf', $this->vdir . '/swf/video.swf'); } - + $this->log('Copied assets'); $this->loadPlugins(); + $this->log('Plugins loaded'); $this->writeImages(); + $this->log('Images written'); $linksCSS = $this->writeLinks(); + $this->log('Links written'); $this->writeCSS($this->vdir . '/data/style/style_%d.css', $linksCSS); + $this->log('CSS written'); $this->writeLangs(); + $this->log('Langs written'); $this->writeIndex(); + $this->log('Index written'); $this->writeTexts(); + $this->log('Texts written'); $this->writeExtras(); + $this->log('Extras written'); $this->writeJs(); + $this->log('Js written'); $this->writeCache(); + $this->log('Cache written'); } protected function loadPlugins() { -- 2.39.5