]> _ Git - cubeextranet.git/commitdiff
Measure time for processing each steps | wip #1475 @0.75
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 14 Jun 2017 15:07:04 +0000 (15:07 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 14 Jun 2017 15:07:04 +0000 (15:07 +0000)
inc/ws/Controlleur/class.ws.ajax.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index cf79efd8950fc4c7e21333a803326b841aa52fca..2aaff30a9f5696f1d22d24e5bfea91bcaae75bf7 100644 (file)
@@ -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') {
index c4c75180a9b83d1d103037fb72b607e76a46b6a8..0533bf4f5c8c79d64aba7a85ac99934147d0dcf4 100644 (file)
@@ -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() {