This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Latency Comparison Numbers | |
-------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LOGFILE="/tmp/lslog" | |
ORIGINAL_LS="/bin/LS" | |
#chmod 777 "${LOGFILE}" | |
WHOAMI=$(whoami) | |
TTY=$(tty) | |
CWD="$(pwd)" | |
PARENT_COMMAND="$(ps -o comm= $PPID)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function grep_r($str,$find) | |
{ | |
return substr($str,$r=strpos($str,$find)+strlen($find),strpos($str,PHP_EOL,$r)-1-$r); | |
} | |
function curl($url,$postparams=[],$headers=[],$additional_opts=[]) | |
{ | |
$opts=[ | |
CURLOPT_COOKIEJAR => 'stdlib.cookie', | |
CURLOPT_COOKIEFILE => 'stdlib.cookie', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TypedPHPException extends Exception { | |
function __construct($msg,$file,$line) | |
{ | |
parent::__construct($msg); | |
$this->file=$file; | |
$this->line=$line; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ZEND_BEGIN_ARG_INFO_EX(phpx_byref_arginfo, | |
1 /*pass_rest_by_reference*/, | |
0/*return_reference*/, | |
1/*required_num_args*/) | |
ZEND_ARG_PASS_INFO(1/*by_ref*/) | |
ZEND_END_ARG_INFO(); | |
PHP_FUNCTION(zval_id) | |
{ | |
//computes the address of first zval sent to it, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ZEND_BEGIN_ARG_INFO_EX(phpx_byref_arginfo, | |
1 /*pass_rest_by_reference*/, | |
0/*return_reference*/, | |
1/*required_num_args*/) | |
ZEND_ARG_PASS_INFO(1/*by_ref*/) | |
ZEND_END_ARG_INFO(); | |
PHP_FUNCTION(is_ref) | |
{ | |
zval *z; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This is a hacky is_ref function. | |
* Determines whether a variable is a reference or not | |
* by using var_dump on its symbol table and | |
* checking whether it has '&' before its value or not. | |
* @param array $defined_vars should send get_defined_vars() to this. enforced. | |
* @param mixed $var any variable, should be a variable and not a expression | |
* @return boolean | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This is a hacky zval_id implementation. | |
* It tries to be as fast as possible, | |
* and can only detect unique arrays, leaving them | |
* modified | |
* When in doubt, assumes it's a new zval! | |
* @param mixed &$zval | |
* @return integer | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* PHP Deep Copy | |
* @version 3.1.1: | |
* _zval_id_accurate now receives its zval pool instead of having it static. | |
* if is_ref and zval_id are available | |
* in PHP core, we will use them. | |
* otherwise, we will use PHP based implementations of these | |
* functions. | |
* |
NewerOlder