コード例 #1
0
ファイル: bobbfunc.php プロジェクト: bobbingwide/oik-lib
 /**
  * Perform nested shortcode expansion
  *
  * @TODO Performance question - is there any point testing for a '[' in the string? i.e. How expensive is do_shortcode() ? 
  *
  * @param string $content - the content to be expanded
  * @return string the content after shortcode expansion
  */
 function bw_do_shortcode($content)
 {
     bw_push();
     $content = do_shortcode($content);
     bw_pop();
     return $content;
 }
コード例 #2
0
ファイル: trac29608.php プロジェクト: bobbingwide/trac29608
/**
 * Compare performance of the two methods
 *
 * Do this regardless of the comparison
 * As it may help decide which is the better solution
 * Especially when the output doesn't actually make much sense regardless of the method chosen.
 */
function trac_29608_perf($value)
{
    $limit = trac_29608_get_field("limit");
    $limit = absint($limit);
    if (!$limit) {
        $limit = 1000;
    }
    bw_push();
    $start = microtime();
    for ($loop = 0; $loop < $limit; $loop++) {
        $result = apply_filters("the_content_pre_29608", $value);
    }
    $middle = microtime();
    for ($loop = 0; $loop < $limit; $loop++) {
        $result = apply_filters("the_content_post_29608", $value);
    }
    $end = microtime();
    bw_pop();
    $pre = bw_get_elapsed($start, $middle);
    $post = bw_get_elapsed($middle, $end);
    //e( "Start: $start ");
    //e( "Middle: $middle ");
    //e( "End: $end " );
    p("Pre: {$pre} ");
    p("Post: {$post}");
    if ($post > $pre) {
        p("Post is slower");
    } elseif ($post == $pre) {
        p("Times match!");
    } else {
        p("Post is faster");
    }
    p("Loops: {$limit} ");
}