本文整理汇总了PHP中KTUtil::getBenchmarkTime方法的典型用法代码示例。如果您正苦于以下问题:PHP KTUtil::getBenchmarkTime方法的具体用法?PHP KTUtil::getBenchmarkTime怎么用?PHP KTUtil::getBenchmarkTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KTUtil
的用法示例。
在下文中一共展示了KTUtil::getBenchmarkTime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upload
function upload(&$oDocument, $sTmpFilePath, $aOptions = null)
{
if (!file_exists($sTmpFilePath)) {
return new PEAR_Error("{$sTmpFilePath} does not exist so we can't copy it into the repository! Options: " . print_r($aOptions, true));
}
$oConfig =& KTConfig::getSingleton();
$sStoragePath = $this->generateStoragePath($oDocument);
if (PEAR::isError($sStoragePath)) {
return $sStoragePath;
}
$this->setPath($oDocument, $sStoragePath);
$oDocument->setFileSize(filesize($sTmpFilePath));
$sDocumentFileSystemPath = sprintf("%s/%s", $oConfig->get('urls/documentRoot'), $this->getPath($oDocument));
//copy the file accross
$start_time = KTUtil::getBenchmarkTime();
$file_size = $oDocument->getFileSize();
if (OS_WINDOWS) {
$sDocumentFileSystemPath = str_replace('\\', '/', $sDocumentFileSystemPath);
}
if ($this->writeToFile($sTmpFilePath, $sDocumentFileSystemPath, $aOptions)) {
$end_time = KTUtil::getBenchmarkTime();
global $default;
$default->log->info(sprintf("Uploaded %d byte file in %.3f seconds", $file_size, $end_time - $start_time));
//remove the temporary file
//@unlink($sTmpFilePath);
if (file_exists($sDocumentFileSystemPath)) {
return true;
} else {
return new PEAR_Error("{$sDocumentFileSystemPath} does not exist after write to storage path. Options: " . print_r($aOptions, true));
}
} else {
return new PEAR_Error("Could not write {$sTmpFilePath} to {$sDocumentFileSystemPath} with options: " . print_r($aOptions, true));
}
}
示例2: upload
function upload(&$oDocument, $sTmpFilePath)
{
$oConfig =& KTConfig::getSingleton();
$sStoragePath = $this->generateStoragePath($oDocument);
$this->setPath($oDocument, $sStoragePath);
$oDocument->setFileSize(filesize($sTmpFilePath));
$sDocumentFileSystemPath = sprintf("%s/%s", $oConfig->get('urls/documentRoot'), $this->getPath($oDocument));
//copy the file accross
$start_time = KTUtil::getBenchmarkTime();
$file_size = $oDocument->getFileSize();
if (copy($sTmpFilePath, $sDocumentFileSystemPath)) {
$end_time = KTUtil::getBenchmarkTime();
global $default;
$default->log->info(sprintf("Uploaded %d byte file in %.3f seconds", $file_size, $end_time - $start_time));
//remove the temporary file
unlink($sTmpFilePath);
if (file_exists($sDocumentFileSystemPath)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
示例3: migrateDocuments
public function migrateDocuments($max = null)
{
global $default;
$default->log->info(_kt('migrateDocuments: starting'));
if (!$this->doesDiagnosticsPass(true)) {
$default->log->info(_kt('migrateDocuments: stopping - diagnostics problem. The dashboard will provide more information.'));
return;
}
if (KTUtil::getSystemSetting('migrationComplete') == 'true') {
$default->log->info(_kt('migrateDocuments: stopping - migration is complete.'));
return;
}
$config =& KTConfig::getSingleton();
if (is_null($max)) {
$max = $config->get('indexer/batchMigrateDocument', 500);
}
$lockFile = $config->get('cache/cacheDirectory') . '/migration.lock';
if (is_file($lockFile)) {
$default->log->info(_kt('migrateDocuments: stopping - migration lockfile detected.'));
return;
}
touch($lockFile);
$startTime = KTUtil::getSystemSetting('migrationStarted');
if (is_null($startTime)) {
KTUtil::setSystemSetting('migrationStarted', time());
}
$maxLoops = 5;
$max = ceil($max / $maxLoops);
$start = KTUtil::getBenchmarkTime();
$noDocs = false;
$numDocs = 0;
for ($loop = 0; $loop < $maxLoops; $loop++) {
$sql = "SELECT\n \t\t\tdocument_id, document_text\n\t\t\t\tFROM\n\t\t\t\t\tdocument_text\n\t\t\t\tORDER BY document_id\n \t\t\t\t\tLIMIT {$max}";
$result = DBUtil::getResultArray($sql);
if (PEAR::isError($result)) {
$default->log->info(_kt('migrateDocuments: db error'));
break;
}
$docs = count($result);
if ($docs == 0) {
$noDocs = true;
break;
}
$numDocs += $docs;
foreach ($result as $docinfo) {
$docId = $docinfo['document_id'];
$document = Document::get($docId);
if (PEAR::isError($document) || is_null($document)) {
$sql = "DELETE FROM document_text WHERE document_id={$docId}";
DBUtil::runQuery($sql);
$default->log->error(sprintf(_kt('migrateDocuments: Could not get document %d\'s document! Removing content!'), $docId));
continue;
}
$version = $document->getMajorVersionNumber() . '.' . $document->getMinorVersionNumber();
$targetFile = tempnam($tempPath, 'ktindexer');
if (file_put_contents($targetFile, $docinfo['document_text']) === false) {
$default->log->error(sprintf(_kt('migrateDocuments: Cannot write to \'%s\' for document id %d'), $targetFile, $docId));
continue;
}
// free memory asap ;)
unset($docinfo['document_text']);
$title = $document->getName();
$indexStatus = $this->indexDocumentAndDiscussion($docId, $targetFile, $title, $version);
if ($indexStatus) {
$sql = "DELETE FROM document_text WHERE document_id={$docId}";
DBUtil::runQuery($sql);
} else {
$default->log->error(sprintf(_kt("migrateDocuments: Problem indexing document %d"), $docId));
}
@unlink($targetFile);
}
}
@unlink($lockFile);
$time = KTUtil::getBenchmarkTime() - $start;
KTUtil::setSystemSetting('migrationTime', KTUtil::getSystemSetting('migrationTime', 0) + $time);
KTUtil::setSystemSetting('migratedDocuments', KTUtil::getSystemSetting('migratedDocuments', 0) + $numDocs);
$default->log->info(sprintf(_kt('migrateDocuments: stopping - done in %d seconds!'), $time));
if ($noDocs) {
$default->log->info(_kt('migrateDocuments: Completed!'));
KTUtil::setSystemSetting('migrationComplete', 'true');
schedulerUtil::deleteByName('Index Migration');
$default->log->debug(_kt('migrateDocuments: Disabling \'Index Migration\' task by removing scheduler entry.'));
}
}
示例4: dirname
$dirname = dirname($file);
chdir($dirname);
$cmd = "\"{$phpPath}\" {$cmd}";
}
if (OS_WINDOWS) {
$default->log->debug("Scheduler - dirname: {$dirname} cmd: {$cmd}");
//$WshShell = new COM("WScript.Shell");
//$res = $WshShell->Run($cmd, 0, true);
KTUtil::pexec($cmd);
} else {
$cmd .= strtolower($sTask) == 'openoffice test' ? ' >/dev/null &' : ' 2>&1';
$default->log->debug("Scheduler cmd: {$cmd}");
$res = shell_exec($cmd);
}
// On completion - reset run time
$iEnd = KTUtil::getBenchmarkTime();
$iDuration = number_format($iEnd - $iStart, 2);
$ignore = array('openoffice test');
if (!empty($res)) {
$func = in_array(strtolower($sTask), $ignore) ? 'debug' : 'info';
$default->log->{$func}("Scheduler - Task: {$sTask}");
$default->log->{$func}("Scheduler - Command: {$cmd}");
$default->log->{$func}("Scheduler - Output: {$res}");
$default->log->{$func}("Scheduler - Background tasks should not produce output. Please review why this is producing output.");
} else {
$default->log->debug("Scheduler - Task: {$sTask} completed in {$iDuration}s.");
}
if (($sFreq == 'once' || empty($sFreq)) && $retval !== FALSE) {
// Set is_complete to true
$aUpdate['is_complete'] = '1';
} else {
示例5: run
/**
* This runs the web service
*
* @static
* @access public
*/
function run()
{
if (defined('JSON_WEBSERVICE')) {
$this->runJSON();
return;
}
ob_start();
$server = new SOAP_Server();
$server->addObjectMap($this, 'http://schemas.xmlsoap.org/soap/envelope/');
$request = 'Not Set';
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
$request = file_get_contents("php://input");
$server->service($request);
} else {
// Create the DISCO server
$disco = new SOAP_DISCO_Server($server, $this->namespace);
header("Content-type: text/xml");
if (isset($_SERVER['QUERY_STRING']) && strcasecmp($_SERVER['QUERY_STRING'], 'wsdl') == 0) {
echo $disco->getWSDL();
} else {
echo $disco->getDISCO();
}
}
$capture = ob_get_flush();
$this->debug($request, 'request', 5);
$this->debug($capture, 'response', 5);
global $_KT_starttime;
$time = number_format(KTUtil::getBenchmarkTime() - $_KT_starttime, 2);
$this->debug($time, 'time from start', 4);
}