Skip to content

Instantly share code, notes, and snippets.

@19h
Created November 28, 2010 21:36
Show Gist options
  • Save 19h/719319 to your computer and use it in GitHub Desktop.
Save 19h/719319 to your computer and use it in GitHub Desktop.
B3NCH 2.3 by Kenan Sulayman.
/* B3NCH.php */
<?php
define( "b3nch_", true );
class b3nch {
//json_encode($a,JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_AMP)
private $cache, $b3nch = array();
private $memc = 0;
public function __b3nch_init () {
// inititalize exts'..
$this->__b3nch_ext_gather();
return count($this->cache[0x8A]);
}
private function __b3nch_ext_gather () {
// Find index
$this->cache[0x8A] = glob("ext/*.b3c");
for ( $i = 0; $i <= count( $this->cache[0x8A] ); ++$i ){
// foreach $(.*?).b3? find the corresponding b3c-configuration.
if (file_exists($p=(substr($this->cache[0x8A][$i],0,strlen($this->cache[0x8A][$i])-4 ).".b3"))){
$q = json_decode ( file_get_contents ( $p ) );
($t = $q->{"Name"}) && ($$t = substr( $p, 4, strlen($p) - 7 ));
if ( $t == $$t ) {
// critical section..
include( $p."c" );
if ( !is_object( $interface ) )
continue;
else
$this->cache[0x8A][$i] = array( $t, $interface, $q );
// ..end.
continue;
} else {
continue;
}
}
}
}
public function __b3nch_rel_init () {
foreach ( $this->cache[0x8A] as $s ) {
print "We now load << " . $s[0] . " >>:";
$s[1]->__ceil( $this->cache[0x8A][2] );
}
print "\r\n\r\n< end >.";
}
}
$b3nch = new b3nch;
print "B3NCH - v1.35, w/o UI.\r\nThe kernel is initializing...";
$q = $b3nch -> __b3nch_init();
print "done.\r\nThe system has found and loaded " . $q . " libraries.\r\n\r\n";
$b3nch->__b3nch_rel_init();
?>
/* ext/acc_n2_stress.b3c */
<?
defined("b3nch_") or die;
final class acc_n2_stress {
private $memc = "";
public function __init ( $z = 1000000, $y = 1 ) {
for($k=$i=$$q=$n=$yx=$yxp=$nq=$p=$r=0, $q=array(); $i <= $z ;++$i, ++$r){
if ( $nq == 0 && $i % $y == 0 ) {
$nq = 1;
$p = $y;
$yx = microtime(1);
}
$k = md5 ( ord(chr($i+mt_rand())) ^ ord(chr(($i+1)+mt_rand())) );
$p = md5 ( ord(chr(($i+1)+mt_rand())) ^ ord(chr($i+mt_rand())) );
$$q = md5(( ord( $k[0] ) + ord( $k[1] ) ) ^ ( ord( $p[0] ) ^ ord( $p[1] ) ) + mt_rand());
$$prt = in_array( $$q, $q ); $q[] = $$q; !in_array( $$q, $q ) ? ++$n : null;
$$t = ( $i % 5 == 0); ( $$t ) ? $n = null : null;
//if ( $r % 100 == 0 )
// print "Iteration: $r \r";
if ( $i % $y == 0 && $p != $y) {
$yxp += microtime(1) - $yx;
$nq = 0;
}
if ( $r == $z )
return array( $yxp / ($r / $y), $yxp );
}
}
private function __mem () {
if ( $this -> memc == 0 ) {
return $this -> memc = memory_get_peak_usage(1) / 1000;
} else {
$p = $this -> memc - ( memory_get_peak_usage(1) / 1000 );
if ( $p <= 0 ) $p *= -1; // if delta[p] < 0, invert.
$this -> memc = 0;
return $p;
}
}
public function __ceil ( $v ) {
print "\r\n\r\nWelcome to b3nch::acc_n2_stress-test. This might take a few minutes.";
$this->__mem();
$k = 25;
for ( $i = $pqw = 0; $i <= $k; ++$i) {
$p = $this -> __init( 1000, 1 );
$prt = $p[1];
$prt /= 1;
$prt *= 1/2;
$prt /= 1;
$prt *= 10000;
$pqw += $prt;
$pqt += $p[0];
}
$prt = $pqw / $k;
$ppp = $pqt / $k;
print "\r\n\r\nResult: " . $prt . " at an average per iteration of: " . $ppp;
print "\r\nMemPeak loaded by ext: " . $this->__mem() . " bytes.";
}
}
$interface = new acc_n2_stress;
?>
/* acc_b2_stress.b3 */
{"Name":"acc_n2_stress","Config":{"Iterations":1000,"k":1,"c_mempeak":true}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment