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


PHP Relation::getAllRelations方法代码示例

本文整理汇总了PHP中Relation::getAllRelations方法的典型用法代码示例。如果您正苦于以下问题:PHP Relation::getAllRelations方法的具体用法?PHP Relation::getAllRelations怎么用?PHP Relation::getAllRelations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Relation的用法示例。


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

示例1: getAffectedInvConjunctIds

 public static function getAffectedInvConjunctIds($fullRelationSignature)
 {
     $allRelations = Relation::getAllRelations();
     if (!array_key_exists($fullRelationSignature, $allRelations)) {
         throw new Exception("Relation \\'{$fullRelationSignature}\\' does not exists in allRelations", 500);
     }
     return (array) $allRelations[$fullRelationSignature]['affectedInvConjunctIds'];
 }
开发者ID:4ZP6Capstone2015,项目名称:Capstone,代码行数:8,代码来源:Relation.php

示例2: conjPerfStats

 /**
  * @url GET stats/performance/conjuncts
  * @param string $groupBy
  * @param int $from
  * @param int $to
  */
 public function conjPerfStats($groupBy = 'conjuncts', $from = 0, $to = 10)
 {
     try {
         if (Config::get('productionEnv')) {
             throw new Exception("Performance tests are not allowed in production environment", 403);
         }
         $performanceArr = array();
         // run all conjuncts (from - to)
         for ($i = $from; $i <= $to; $i++) {
             $conj = RuleEngine::getConjunct('conj_' . $i);
             $startTimeStamp = microtime(true);
             // true means get as float instead of string
             RuleEngine::checkConjunct('conj_' . $i, false);
             $endTimeStamp = microtime(true);
             $performanceArr['conj_' . $i] = array('id' => 'conj_' . $i, 'start' => $startTimeStamp, 'end' => $endTimeStamp, 'duration' => $endTimeStamp - $startTimeStamp, 'invariantRules' => implode(';', $conj['invariantRuleNames']), 'signalRules' => implode(';', $conj['signalRuleNames']));
         }
         switch ($groupBy) {
             case 'conjuncts':
                 return array_values($performanceArr);
                 break;
             case 'rules':
                 $ruleArr = array();
                 foreach (RuleEngine::getAllRules() as $rule) {
                     $duration = 0;
                     foreach ($rule['conjunctIds'] as $conj) {
                         $duration += $performanceArr[$conj]['duration'];
                     }
                     $ruleArr[] = array('ruleName' => $rule['name'], 'duration' => $duration, 'conjuncts' => implode(';', $rule['conjunctIds']));
                 }
                 return $ruleArr;
                 break;
             case 'relations':
                 $relArr = array();
                 foreach (Relation::getAllRelations() as $sig => $rel) {
                     $duration = 0;
                     $conjuncts = array_merge($rel['affectedInvConjunctIds'], $rel['affectedSigConjunctIds']);
                     foreach ($conjuncts as $conj) {
                         $duration += $performanceArr[$conj]['duration'];
                     }
                     $relArr[] = array('relationSignature' => $sig, 'duration' => $duration, 'conjuncts' => implode(';', $conjuncts));
                 }
                 return $relArr;
                 break;
             default:
                 throw new Exception("Unknown groupBy argument", 500);
                 break;
         }
     } catch (Exception $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     }
 }
开发者ID:4ZP6Capstone2015,项目名称:ampersand,代码行数:57,代码来源:Api.php


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