当前位置: 首页>>代码示例>>PHP>>正文


PHP elapsed函数代码示例

本文整理汇总了PHP中elapsed函数的典型用法代码示例。如果您正苦于以下问题:PHP elapsed函数的具体用法?PHP elapsed怎么用?PHP elapsed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了elapsed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: returnAjax

 function returnAjax($data)
 {
     /***
      * Return the data as a JSON object
      *
      * @param array $data
      *
      ***/
     if (!is_array($data)) {
         $data = array($data);
     }
     $data["execution_time"] = elapsed();
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     header('Content-type: application/json');
     // try {
     //     foreach($data as $col=>$val) {
     //         $clean = deEscape($val);
     //         if(!empty($clean)) $data[$col] = $clean;
     //     }
     // } catch (Exception $e) {
     // }
     $json = json_encode($data, JSON_FORCE_OBJECT);
     $replace_array = array(""", """);
     #$deescaped = htmlspecialchars_decode(html_entity_decode($json));
     #$dequoted = str_replace($replace_array,"\\\"",$deescaped);
     $dequoted_bare = str_replace($replace_array, "\\\"", $json);
     $de2 = htmlspecialchars_decode(html_entity_decode($dequoted_bare));
     #print $deescaped;
     # print $dequoted_bare;
     print $de2;
     #print htmlspecialchars_decode(html_entity_decode(urldecode($json)));
     exit;
 }
开发者ID:AmphibiaWeb,项目名称:amphibian-disease-tracker,代码行数:34,代码来源:core.php

示例2: init

 /** Module initialization */
 public function init(array $params = array())
 {
     // TODO: Add control over tools installation
     // TODO: Add control over tool output/returnval to signal error
     // Get web-application supported images
     foreach ($this->getImagesList($this->supported) as $extension => $images) {
         // Iterate all images with this extension
         foreach ($images as $image) {
             // Generate hash string describing
             $cacheFile = md5($image) . '.' . $extension;
             // Check if cache file has to be updated
             if ($this->cache_refresh($cacheFile, false)) {
                 elapsed('Lossless compressing image: ' . $image);
                 // Dependently on image extension use specific tool for compression
                 switch ($extension) {
                     case 'jpg':
                     case 'jpeg':
                         exec('jpegoptim ' . $image);
                         break;
                     case 'png':
                         exec('optipng -o7 ' . $image);
                         break;
                     default:
                         elapsed('Image:' . $image . ' cannot be compressed, extension not supported');
                 }
                 // Store cached empty image version to avoid duplicate compressing
                 file_put_contents($cacheFile, '');
             }
         }
     }
 }
开发者ID:samsonos,项目名称:php_optimage,代码行数:32,代码来源:OptImage.php

示例3: disk

function disk($file, $value = '§k¥', $duration = '30 days')
{
    global $skyphp_storage_path;
    $file = implode('/', array_filter(explode('/', $file)));
    $cache_file = $skyphp_storage_path . 'diskcache/' . $file;
    //echo 'cachefile: ' . $cache_file . '<br />';
    if ($value == '§k¥') {
        // read
        elapsed("begin disk-read({$file})");
        if (is_file($cache_file) && filesize($cache_file)) {
            // if the file exists, open the file and get the expiration time
            $fh = fopen($cache_file, 'r');
            $value = fread($fh, filesize($cache_file));
            $needle = "\n";
            $break = strpos($value, $needle);
            $expiration_time = substr($value, 0, $break);
            $value = substr($value, $break + strlen($needle));
            fclose($fh);
            if ($expiration_time > time()) {
                // if the file is not expired, return the value
                elapsed("end disk-read({$file})");
                return $value;
            } else {
                // file is expired, delete the file
                elapsed("end disk-read({$file})");
                unlink($cache_file);
            }
        }
        return false;
    } else {
        // write
        elapsed("begin disk-write({$file})");
        // set the value on disk
        $expiration_time = strtotime($duration);
        $value = $expiration_time . "\n" . $value;
        $end = strrpos($cache_file, '/');
        $cache_dir = substr($cache_file, 0, $end);
        //echo 'cachedir: ' . $cache_dir . "<br />";
        @mkdir($cache_dir, 0777, true);
        touch($cache_file);
        $fh = fopen($cache_file, 'w') or die("can't open cache file");
        fwrite($fh, $value);
        fclose($fh);
        elapsed("end disk-write({$file})");
        return true;
    }
}
开发者ID:HotwireCommunications,项目名称:skyphp,代码行数:47,代码来源:functions.inc.php

示例4: returnAjax

function returnAjax($data)
{
    /***
     * Return the data as a JSON object
     *
     * @param array $data
     *
     ***/
    if (!is_array($data)) {
        $data = array($data);
    }
    $data["execution_time"] = elapsed();
    header('Cache-Control: no-cache, must-revalidate');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Content-type: application/json');
    $json = json_encode($data, JSON_FORCE_OBJECT);
    $replace_array = array("&quot;", "&#34;");
    print str_replace($replace_array, "\\\"", $json);
    exit;
}
开发者ID:AmphibiaWeb,项目名称:amphibian-disease-tracker,代码行数:20,代码来源:oauth_login_handler.php

示例5: returnAjax

function returnAjax($data)
{
    /***
     * Return the data as a JSON object. This function, when called,
     * will exit the script.
     *
     * @param array $data
     *
     ***/
    if (!is_array($data)) {
        $data = array($data);
    }
    $data['execution_time'] = elapsed();
    header('Cache-Control: no-cache, must-revalidate');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Content-type: application/json');
    $json = json_encode($data, JSON_FORCE_OBJECT);
    $replace_array = array('&quot;','&#34;');
    print str_replace($replace_array, '\\"', $json);
    exit();
}
开发者ID:AmphibiaWeb,项目名称:amphibian-disease-tracker,代码行数:21,代码来源:meta.php

示例6: returnAjax

 function returnAjax($data)
 {
     if (!is_array($data)) {
         $data = array($data);
     }
     $data['execution_time'] = elapsed();
     $data['completed'] = microtime_float();
     global $do;
     $data['requested_action'] = $do;
     $data['args_provided'] = $_REQUEST;
     if (!isset($data['status'])) {
         $data['status'] = false;
         $data['error'] = 'Server returned null or otherwise no status.';
         $data['human_error'] = "Server didn't respond correctly. Please try again.";
         $data['app_error_code'] = -10;
     }
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     header('Content-type: application/json');
     global $billingTokens;
     if (is_array($billingTokens)) {
         $data['billing_meta'] = $billingTokens;
     }
     // try {
     //     foreach($data as $col=>$val) {
     //         $data[$col] = deEscape($val);
     //     }
     // } catch (Exception $e) {
     // }
     $json = json_encode($data, JSON_FORCE_OBJECT);
     $replace_array = array("&quot;", "&#34;");
     $deescaped = htmlspecialchars_decode(html_entity_decode($json));
     $dequoted = str_replace($replace_array, "\\\"", $deescaped);
     $dequoted_bare = str_replace($replace_array, "\\\"", $json);
     $de2 = htmlspecialchars_decode(html_entity_decode($dequoted_bare));
     #print $deescaped;
     # print $dequoted_bare;
     print $de2;
     exit;
 }
开发者ID:AmphibiaWeb,项目名称:amphibian-disease-tracker,代码行数:40,代码来源:async_login_handler.php

示例7: getFeed

 public function getFeed($who, $limit = 50, $offset = 0)
 {
     if (!is_array($who)) {
         $who = array($who);
     }
     $who_array = $who;
     foreach ($who_array as $who) {
         if ($who_csv) {
             $who_csv .= ',';
         }
         $who_csv .= "'{$who}'";
     }
     // return a distinct field in a table with an order by
     $where = "who in ( {$who_csv} )";
     $order_by = 'news_who.insert_time desc';
     $person_id = PERSON_ID ? PERSON_ID : 0;
     $sql = "\n            SELECT news_item_id FROM (\n                SELECT DISTINCT ON (q.news_item_id) news_item_id, row FROM (\n                    SELECT\n                        news_who.news_item_id,\n                        row_number() OVER (ORDER BY {$order_by}) AS row\n                    FROM news_who\n                    LEFT JOIN news_hide on news_hide.news_item_id = news_who.news_item_id\n                        and news_hide.person_id = {$person_id}\n                        and news_hide.active = 1\n                    LEFT JOIN news_item on news_item.id = news_who.news_item_id\n                    WHERE news_who.active = 1\n                    AND news_item.active = 1\n                    AND news_hide.id is null\n                    AND {$where}\n                    ORDER BY {$order_by}\n                    OFFSET {$offset}\n                    LIMIT {$limit}\n                ) AS q\n            ) AS fin ORDER BY row";
     //print_pre($sql);
     elapsed('before news query');
     $arr = sql_array($sql);
     elapsed('after news query');
     return $arr;
 }
开发者ID:hshoghi,项目名称:cms,代码行数:23,代码来源:class.news.php

示例8: microtime

}
$syck_stop = microtime();
$test_str = serialize($test_obj);
$unser_start = microtime();
foreach (range(0, $iter) as $i) {
    $test_obj = unserialize($test_str);
}
$unser_stop = microtime();
$doc2 = "";
foreach (range(0, $iter) as $i) {
    $doc2 .= $doc . "\n";
}
echo "DOC #2 = 1 x " . strlen($doc2) . "\n";
$syck2_start = microtime();
$test_obj = syck_load($doc2);
$syck2_stop = microtime();
$test_str = serialize($test_obj);
$unser2_start = microtime();
$test_obj = unserialize($test_str);
$unser2_stop = microtime();
function elapsed($start, $stop)
{
    $start_mt = explode(" ", $start);
    $stop_mt = explode(" ", $stop);
    $start_total = doubleval($start_mt[0]) + $start_mt[1];
    $stop_total = doubleval($stop_mt[0]) + $stop_mt[1];
    return sprintf("%0.6f", $stop_total - $start_total);
}
echo "syck:  " . elapsed($syck_start, $syck_stop) . " " . elapsed($syck2_start, $syck2_stop) . "\n";
echo "php:   " . elapsed($unser_start, $unser_stop) . " " . elapsed($unser2_start, $unser2_stop) . "\n";
开发者ID:andreassylvester,项目名称:syck,代码行数:30,代码来源:syck.php

示例9: render

 public function render(array $db_rows = null, $module = null)
 {
     // Rows HTML
     $rows = '';
     // if no rows data is passed - perform db request
     if (!isset($db_rows)) {
         $db_rows = $this->query->exec();
     }
     // If we have table rows data
     if (is_array($db_rows)) {
         // Save quantity of rendering rows
         $this->last_render_count = sizeof($db_rows);
         // Debug info
         $rn = 0;
         $rc = sizeof($db_rows);
         // Iterate db data and perform rendering
         foreach ($db_rows as &$db_row) {
             if ($this->debug) {
                 elapsed('Rendering row ' . $rn++ . ' of ' . $rc . '(#' . $db_row->id . ')');
             }
             $rows .= $this->row($db_row, $this->pager);
             //catch(\Exception $e){ return e('Error rendering row#'.$rn.' of '.$rc.'(#'.$db_row->id.')'); }
         }
     } else {
         $rows .= $this->emptyrow($this->query, $this->pager);
     }
     //elapsed('render pages: '.$this->pager->total);
     // Render table view
     return m($module)->view($this->table_tmpl)->set($this->pager)->rows($rows)->output();
 }
开发者ID:samsonos,项目名称:cms_app_material,代码行数:30,代码来源:FormFieldTable.php

示例10: migrate_8_to_9

 public function migrate_8_to_9()
 {
     elapsed('Adding `filter` table');
     elapsed('Adding `filtered` field into `field` table');
     // SQL комманда на создание таблицы фильтров
     $sql_filter = "CREATE TABLE IF NOT EXISTS `" . dbMySQLConnector::$prefix . "filter` (\n\t\t  `filter_id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t  `field_id` int(11) NOT NULL,\n\t\t  `value` varchar(255) NOT NULL,\n\t\t  `locale` VARCHAR( 10 ) NOT NULL,\n\t\t  PRIMARY KEY (`filter_id`)\n\t\t) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;";
     db()->query($sql_filter);
     db()->query('ALTER TABLE  `' . dbMySQLConnector::$prefix . 'field` ADD  `filtered` INT( 10 ) NOT NULL AFTER  `local`');
 }
开发者ID:rmolodyko,项目名称:cms_api,代码行数:9,代码来源:CMS.php

示例11: elapsed

                            class="ide"
                            >
                            <?php 
                    echo $col['table_name'];
                    ?>
 (<?php 
                    echo $count;
                    ?>
)
                        </a>
                    </p>
<?php 
                }
            }
        }
        elapsed('after foreach cols');
    } else {
        echo 'No Data';
    }
} else {
    ?>
        <br /><br />
        <div id="goIde" style="text-align: center;">
            <input type="text" id="ide" name="ide" style="font-size: 2em;"/>
            <input type="button" id="ideGo" value="Go &raquo;" onclick="goIde(this)" style="font-size: 2em;"/>
        </div>
<?php 
}
?>

</div>
开发者ID:hshoghi,项目名称:cms,代码行数:31,代码来源:ide.php

示例12: generate_nodes

 private function generate_nodes($read_db = NULL)
 {
     global $repmgr_cluster_name, $db;
     elapsed("repmgr generate_nodes start");
     $conninfo_host_key = 'host=';
     $sql = "select id, cluster, conninfo, case when strpos(conninfo, '{$conninfo_host_key}') > 0 then substr(conninfo, strpos(conninfo, '{$conninfo_host_key}') + length('{$conninfo_host_key}'), strpos(substr(conninfo, strpos(conninfo, '{$conninfo_host_key}')), ' ') - 1 - length('{$conninfo_host_key}')) else NULL end as host from repmgr_{$repmgr_cluster_name}.repl_nodes where cluster = '{$repmgr_cluster_name}'";
     $unused_nodes = array();
     elapsed('repmgr generate_nodes query 1 start');
     if ($rs = $db->Execute($sql)) {
         elapsed('repmgr generate_nodes query 1 end');
         elapsed('repmgr generate_nodes query 1 start process data');
         while (!$rs->EOF) {
             $unused_nodes[$id = $rs->Fields('id')] = array('id' => $id, 'type' => 'unused', 'host' => $rs->Fields('host'), 'conninfo' => $rs->Fields('conninfo'));
             $rs->MoveNext();
         }
         elapsed('repmgr generate_nodes query 1 end process data');
         unset($rs, $sql, $id);
     }
     if ($read_db == 'localhost') {
         $read_db = trim(rtrim(`hostname`));
     }
     $sql = "select p_nodes.cluster, s_nodes.conninfo as standby_conninfo, p_nodes.conninfo as primary_conninfo, substr(s_nodes.conninfo, strpos(s_nodes.conninfo, '{$conninfo_host_key}') + length('{$conninfo_host_key}'), strpos(substr(s_nodes.conninfo, strpos(s_nodes.conninfo, '{$conninfo_host_key}')), ' ') - 1 - length('{$conninfo_host_key}')) as standby_host, substr(p_nodes.conninfo, strpos(p_nodes.conninfo, '{$conninfo_host_key}') + length('{$conninfo_host_key}'), strpos(substr(p_nodes.conninfo, strpos(p_nodes.conninfo, '{$conninfo_host_key}')), ' ') - 1 - length('{$conninfo_host_key}')) as primary_host, standby_node, primary_node, time_lag from repmgr_{$repmgr_cluster_name}.repl_nodes as s_nodes inner join repmgr_{$repmgr_cluster_name}.repl_status s_status on s_nodes.id = s_status.standby_node inner join repmgr_{$repmgr_cluster_name}.repl_nodes as p_nodes on s_status.primary_node = p_nodes.id where p_nodes.cluster = '{$repmgr_cluster_name}';";
     #       $sql = "select p_nodes.cluster, s_nodes.conninfo as standby_conninfo, p_nodes.conninfo as primary_conninfo, substr(s_nodes.conninfo, strpos(s_nodes.conninfo, '$conninfo_host_key') + length('$conninfo_host_key'), strpos(substr(s_nodes.conninfo, strpos(s_nodes.conninfo, '$conninfo_host_key')), ' ') - 1 - length('$conninfo_host_key')) as standby_host, substr(p_nodes.conninfo, strpos(p_nodes.conninfo, '$conninfo_host_key') + length('$conninfo_host_key'), strpos(substr(p_nodes.conninfo, strpos(p_nodes.conninfo, '$conninfo_host_key')), ' ') - 1 - length('$conninfo_host_key')) as primary_host, standby_node, primary_node from repmgr_$repmgr_cluster_name.repl_nodes as s_nodes inner join (select distinct primary_node, standby_node from repmgr_$repmgr_cluster_name.repl_monitor) as s_status on s_nodes.id = s_status.standby_node inner join repmgr_$repmgr_cluster_name.repl_nodes as p_nodes on s_status.primary_node = p_nodes.id where p_nodes.cluster = '$repmgr_cluster_name';";
     elapsed('repmgr generate_nodes query 2 start');
     if ($rs = $db->Execute($sql)) {
         elapsed('repmgr generate_nodes query 2 end');
         elapsed('repmgr generate_nodes query 2 start process data');
         $primary_nodes = array();
         $standby_nodes = array();
         while (!$rs->EOF) {
             if (!$primary_nodes[$primary_node = $rs->Fields('primary_node')]) {
                 $primary_nodes[$primary_node] = array('id' => $primary_node, 'type' => 'primary', 'host' => $rs->Fields('primary_host'), 'conninfo' => $rs->Fields('primary_conninfo'));
             }
             if (!$standby_nodes[$standby_node = $rs->Fields('standby_node')]) {
                 $standby_nodes[$standby_node] = array('id' => $standby_node, 'type' => 'standby', 'host' => $rs->Fields('standby_host'), 'conninfo' => $rs->Fields('standby_conninfo'), 'roles' => array(array('primary_node_id' => $primary_node, 'time_lag' => $rs->Fields('time_lag'))));
             } else {
                 $standby_nodes[$standby_node]['roles'][] = array('primary_node_id' => $primary_node, 'time_lag' => $rs->Fields('time_lag'));
             }
             if ($standby_nodes[$standby_node]['host'] == $read_db) {
                 $this->set_write_db($primary_nodes[$primary_node]['host']);
                 $this->current_node =& $standby_nodes[$standby_node];
             }
             $rs->MoveNext();
             unset($unused_nodes[$primary_node], $unused_nodes[$standby_node], $primary_node, $standby_node);
         }
         elapsed('repmgr generate_nodes query 2 end process data');
         $this->primary_nodes = $primary_nodes;
         $this->standby_nodes = $standby_nodes;
         $this->unused_nodes = $unused_nodes;
         unset($rs, $sql, $primary_nodes, $standby_nodes, $conninfo_host_key, $unused_nodes);
     } else {
         return NULL;
     }
     elapsed("repmgr generate_nodes end");
     return true;
 }
开发者ID:HotwireCommunications,项目名称:skyphp,代码行数:56,代码来源:class.repmgr.php

示例13: get_disp_status

function get_disp_status($row_in)
{
    // 4/26/11
    extract($row_in);
    $tags_arr = explode("/", get_variable('disp_stat'));
    if (is_date($u2farr)) {
        return "<SPAN CLASS='disp_stat'>&nbsp;{$tags_arr[4]}&nbsp;" . elapsed($u2farr) . "</SPAN>";
    }
    if (is_date($u2fenr)) {
        return "<SPAN CLASS='disp_stat'>&nbsp;{$tags_arr[3]}&nbsp;" . elapsed($u2fenr) . "</SPAN>";
    }
    if (is_date($on_scene)) {
        return "<SPAN CLASS='disp_stat'>&nbsp;{$tags_arr[2]}&nbsp;" . elapsed($on_scene) . "</SPAN>";
    }
    if (is_date($responding)) {
        return "<SPAN CLASS='disp_stat'>&nbsp;{$tags_arr[1]}&nbsp;" . elapsed($responding) . "</SPAN>";
    }
    if (is_date($dispatched)) {
        return "<SPAN CLASS='disp_stat'>&nbsp;{$tags_arr[0]}&nbsp;" . elapsed($dispatched) . "</SPAN>";
    }
}
开发者ID:sharedgeo,项目名称:TicketsCAD-SharedGeo-Dev,代码行数:21,代码来源:functions.inc.php

示例14: sprintf

<?php

global $website, $cache_refresh;
?>

<section id="list-places"> <!-- state/place list -->
   <a id="markets_list" name="markets_list"></a>
   <span class="list-caption">choose city for your new year's destination</span>
	<nav>
<?php 
$cache_name = sprintf('jwebsite:%/id:markets_footer', $website->ct_promoter_website_id);
if (!$cache_refresh) {
    \elapsed("Footer : Getting the markets from cache");
    $markets = mem($cache_name);
}
if (!$markets) {
    $markets = [];
    $marketIds = \Crave\Model\market::getSlugsFeed(['ct_promoter_website_id' => $website->ct_promoter_website_id, 'where' => ["country_code='US'"], 'order_by' => 'name']);
    foreach ($marketIds as $marketId) {
        $market = new \Crave\Model\Market($marketId);
        if (!$market->country_code) {
            $market->country_code = 'us';
        }
        $market->url = strtolower("/" . $market->slug);
        $markets[] = $market;
    }
    mem($cache_name, $markets, '10 hours');
}
$panels = [];
$delimiter_index = ceil(count($markets) / 6);
$index = -1;
开发者ID:BWemagid,项目名称:downtown,代码行数:31,代码来源:footer_markets.php

示例15: error

                $db = &ADONewConnection($db_platform);
                @$db->Connect($db_host, $db_username, $db_password, $db_name);
            
                if ($db->ErrorMsg()) {
                    // connection to the standby failed, try the next one
                    $db_error .= "db error ($db_host): {$db->ErrorMsg()}. \n";
                    continue;
                }
            
                // we connected
                break;
            
            }
            */
        }
    }
    // unset temp connection resource
    unset($d);
    // if the master is our only connection, use it for reads also
    if ($dbw && !$db) {
        $db =& $dbw;
        $db_host = $dbw_host;
    }
    // if we are missing both master and slave, display 503 down for maintenance message
    if (!$db && !$dbw) {
        include 'pages/503.php';
        die("<!-- {$db_error} -->");
    }
}
elapsed('db-connect end');
开发者ID:HotwireCommunications,项目名称:skyphp,代码行数:30,代码来源:db-connect.php


注:本文中的elapsed函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。