Page 1 of 1

Slow application

Posted: Tue Oct 13, 2009 3:50 pm
by Wolfie
Hi all,

I don't know if it is correct part of formum for this topic but I will try.....if not please move to proper part.


I have some aplication - mail client which is very slow because of imap_open function repetition each time calling request.

This is MVC architecture, all request goes thru index.php than to controllers which perform actions.

For example while sending login and password it goes to mailbox function which looks like this :

Code: Select all

 
function mailbox() {
                $_SESSION['login'] =  $_POST['mailbox'];
                $_SESSION['pass'] = $_POST['pass'];
                if(($this->model->connect('gmail.com',$_SESSION['login'],$_SESSION['pass'],'993','imap')) == false) {
                    $this->view = new LoginView;
                    $this->view->display('login');
                    echo 'Wrong login or/and password!';
                } else {
                    //echo 'Loged!';
                    $this->model->inbox();
                    $view = new LoginView;
                    $boxes = $this->model->getMailboxes();
                    $msgsParts = $this->model->getMsgsParts(333);
                    $view->setVars('boxes', $boxes);
                    $view->setVars('parts',$msgsParts);
                    $view->display($_POST['action']);
                }
        }
 
Here we have the line :

Code: Select all

 
$this->model->connect('gmail.com',$_SESSION['login'],$_SESSION['pass'],'993','imap')
 
Which is the model function containing imap_open php function

Than when the user wants to see the specific message he is sending the request over bootstrap (index.php) to other controller which looks like this :

Code: Select all

 
function mailbox() {
            //echo 'MailboxController action mailbox!';
            print_r($_SESSION);
            $this->model->connect('gmail.com',$_SESSION['login'],$_SESSION['pass'],'993','imap');
            $this->model->reconnect($_POST['mailbox']);
            $view = new LoginView;
            $boxes = $this->model->getMailboxes();
            $msgsParts = $this->model->getMsgsParts(3);
            $view->setVars('boxes', $boxes);
            $view->setVars('parts',$msgsParts);
            $view->display($_POST['action']);
        }
        
        function message($params) {
            print_r($params['id']);
            $view = new LoginView;
            $this->model->connect('gmail.com',$_SESSION['login'],$_SESSION['pass'],'993','imap');
            $view->setVars('message', $this->model->getMessage($params['id']));
            $view->display('message');
        }
 
As u can see in every function I have to call the model to connect to mail server with imap_open and this takes enormous amount of time, about 5 sec while changing mailbox (INBOX, Spambox ect.) and one second to see the specific message.

Any idea how to accelerate the application ?

Re: Slow application

Posted: Thu Oct 15, 2009 12:09 pm
by Christopher
Moved to PHP Code.