为什么parse.com PHP SDK这么慢?

时间:2014-10-16 06:09:15

标签: php performance time sdk parse-platform

我使用Parse作为网站(PHP)和iOS(Cocoa)之间的桥梁。当我尝试通过PHP SDK创建新用户时,通常需要超过1秒(大多数为2秒),并且与创建常规PFObject(0.5 - 1.5秒)相同。

我创建用户的代码:

        Debugger::timer('ps_new_user'); //start timer

        $user = new ParseUser();
        $user->set("username", $login);
        $user->set("password", $pass);
        $user->set("email", $email);
        $user->set("phone", $tel);

        try {
          $user->signUp(); //save to PARSE.com
          $elapsed_ps_new_user = Debugger::timer('ps_new_user'); // stop timer if succeeded 

        } catch (ParseException $ex) {                  
            // log all exceptions in case of error
            Debugger::log ("Error: " . $ex->getCode() . " " . $ex->getMessage());
            Debugger::dump($user);  
            $elapsed_ps_new_user = Debugger::timer('ps_new_user');  //stop timer if error     
        }

如果一切顺利,上面的代码通常需要1.5秒甚至更多。

当我使用该代码向Parse.com保存/创建新对象时:

Debugger::timer('ps_new_obj'); //start timer

$newParseObject = ParseObject::create("Orders");
$newParseObject->set("oid", strval($oid));
$newParseObject->set("uid", strval($uid));
$newParseObject->set("date", $datum);
$newParseObject->set("name", $jmeno);
$newParseObject->set("street", $ulice);
$newParseObject->set("city", $mesto);
$newParseObject->set("zip", $psc);
$newParseObject->set("tel", $tel);
$newParseObject->set("email", $email);
$newParseObject->set("price", strval($cena));
$newParseObject->set("note", $pozn);
$newParseObject->set("text", $text);
$newParseObject->set("printed", strval($vytisknuto));

try {
    $newParseObject->save(); //save to Parse.com
    $elapsed_ps_new_obj = Debugger::timer('ps_new_obj'); //stop timer

} catch (ParseException $ex) {
        // log all exceptions
          Debugger::log ("Error: " . $ex->getCode() . " " . $ex->getMessage());
          Debugger::dump($newParseObject);  
          $elapsed_ps_new_obj = Debugger::timer('ps_new_obj'); // stop timer
}

上面的代码需要0.5秒以上。哪个比创建新用户更好,但可能更好。如何加快整个过程?

0 个答案:

没有答案