$_GET['var'] = 'sldkfhlsakhlshglzkdhzfgldznfdznbldzknb';
$array = array_fill(0,100000,"a");
$hash = array(); for ($i=0;$i<100000;$i++) $hash[$i] = $i;
+$a = $b = '';
echo "Start benchmark\n";
/*
#function _isset() { isset($var); } nb::benchmark('_isset',5000000);
#function _in_array() { in_array(5000,$GLOBALS['array']); } nb::benchmark('_in_array',1000);
#function _in_hash() { isset($GLOBALS['hash'][5000]); } nb::benchmark('_in_hash',1000);
+function _and() { $a='' and $b=''; } nb::benchmark('_and',9999999);
+function _sig_and() { $a='' and $b=''; } nb::benchmark('_sig_and',9999999);
+nb::benchmark(); exit;
function _1() { date_default_timezone_set('Europe/London'); } nb::benchmark('_1');
function _2() { error_reporting(E_ALL | E_STRICT | E_NOTICE); } nb::benchmark('_2');
function _3() { ini_set('include_path','.'); } nb::benchmark('_3');
if ($function === null) {
$prev = $_benchmark['.'];
- echo "Iteration: $limit\n";
+ echo "Results: $limit\n";
foreach ($_benchmark as $lib => $sec) {
if ($lib === '.') continue;
printf("%-30s %s\n",$lib,($sec-$prev));
$function();
}
+ echo "Completed: $function\n";
$_benchmark[$function] = microtime(true);
}
<?php
require_once(dirname(__FILE__).'/nb.php');
-# NB 07.03.16 define('OUT_BRACKET1','['.NB_EOL);
-# NB 07.03.16 define('OUT_BRACKET2',']');
-# NB 07.03.16 define('OUT_BRACE1','{'.NB_EOL);
-# NB 07.03.16 define('OUT_BRACE2','}');
-# NB 07.03.16 define('OUT_COMA',','.NB_EOL);
Class Out extends Nb {
if (!self::is_hash($row)) return out_yaml($row,$o);
# text
- foreach ($row as $k => $v) { echo sprintf("%-".(!empty($o['head_max_len']) ? $o['head_max_len']+1 : 10)."s: %s\n",$k,out::escape($v)); }
- #foreach ($row as $k => $v) { echo "$k: ".out::escape($v)."\n"; }
+ foreach ($row as $k => $v) { echo sprintf("%-".(!empty($o['head_max_len']) ? $o['head_max_len']+1 : 10)."s: %s\n",$k,self::escape($v)); }
+ #foreach ($row as $k => $v) { echo "$k: ".self::escape($v)."\n"; }
return true;
}
$head = self::head($conf,$head,$data);
foreach ($data as $row) {
- if ($count>0) out::concat($conf);
+ if ($count>0) self::concat($conf);
$count++;
# Transform simple array into hash
static $replace_flags = null;
$is_scalar = is_scalar($v);
- $v = out::scalar($v);
+ $v = self::scalar($v);
if ($v==='') $is_scalar = true;
if ($replace_flags === null) {
}
$v = htmlspecialchars($v,$replace_flags,strtoupper(self::$charset));
- if (!$is_scalar) $v = '<pre>'.NB_EOL.$v.NB_EOL.'</pre>';
+ if (!$is_scalar and strpos($type,'html') !== false) $v = '<pre>'.NB_EOL.$v.NB_EOL.'</pre>';
return $v;
}
$values = array();
foreach (array_values($row) as $k=>$v) {
- $values[] = preg_replace('/zAZA/','',out::scalar($v));
+# NB 06.04.16 $values[] = preg_replace('/zAZA/','',out::scalar($v));
+ $values[] = out::scalar($v);
#$values[] = preg_replace('/\r?\n/','',out::scalar($v));
}
# Inside tag, ex: label
if (isset($o['tag_key'])) {
- $v = '<'.$o['tag_key'].'>'.$k.'</'.$o['tag_key'].'>'.$v;
+ $v = '<'.$o['tag_key'].'>'.$k.'</'.preg_replace('/ .*$/','',$o['tag_key']).'>'.$v;
}
# Tag = o[tag] or key
;
}
- if (isset($o['tag_enclose'])) echo (NB_EOL ? ' ' : '').'</'.preg_replace('/ .*$/','',$o['tag_enclose']).'>'.NB_EOL;
+ if (isset($o['tag_enclose'])) echo (NB_EOL ? ' ' : '').'</'.preg_replace('/ .*$/','',$o['tag_enclose']).'>'.NB_EOL;
}
function out_xml(&$row,$o) {
public function headers() {
#header('Content-type: ' . self::$content_type);
- $c = strtoupper ( self::$charset );
-# NB 19.08.15 $this->header('Content-type: ',self::$content_type . ($c ? "; charset=$c" : ""));
- header('Content-type: '.self::$content_type . ($c ? "; charset=$c" : ""));
+ header('Content-type: '.self::$content_type . (($c = strtoupper ( self::$charset )) ? "; charset=$c" : ""));
+
if (self::p('download-attachment')) header('Content-Disposition: attachment; filename="'
. $this->title2filename($this->title,self::$content_type)
);