看到一个blog谈到var_export这个函数,于是测试了下和serialize之间的效率对比,结果比我想象还大
$funcs=get_defined_functions();
$t1=microtime(true);
for($i=0;$i<1000;++$i){
file_put_contents('test1.txt',var_export($funcs,true));
eval(file_get_contents('test1.txt').';');
}
$t2=microtime(true);
for($i=0;$i<1000;++$i){
file_put_contents('test2.txt',serialize($funcs));
unserialize(file_get_contents('test2.txt'));
}
$t3=microtime(true);
echo "var_export cost ".($t2-$t1)."\n";
echo "serialize cost ".($t3-$t2)."\n";
//var_export cost 9.58075594902
//serialize cost 3.66198205948
分享到:
相关推荐
使用 MFC 串行化数据和 C++ 对象,三个简单的例子程序
Raphael.JSON Raphael.Export Raphael.FreeTransform raphael.serialize
实现利用serialize()函数序列化文档和鼠标画一些简单的图形的功能.
今天偶然在想,如果用PHP写一个类似BDB的基于文件的Key-Value小型数据库用于存储非结构化的记录型数据,不知道效率会如何?
Serialize-javascript 能够序列化 JavaScript 库成含有正则表达式和功能的 JSON 包。示例:var serialize = require('serialize-javascript'); serialize({ str : 'string', num : 0, obj : {foo: ...
serialize_precision = 100 allow_call_time_pass_reference = Off safe_mode = Off safe_mode_gid = Off safe_mode_include_dir = safe_mode_exec_dir = safe_mode_allowed_env_vars = PHP_ safe_mode_protected_...
python库,解压后可用。 资源全名:flask_serialize-1.5.2-py2.py3-none-any.whl
虽然这样做,它保留了与PHP的序列化机制(相关联的所有语义__wakeup , __sleep , Serializable , __serialize , __unserialize )。 它还提供了一个实例化器,该实例化器允许创建和填充对象而无需... 与var_export
资源分类:Python库 所属语言:Python 使用前提:需要解压 资源全名:flask_serialize-1.0.9-py2.py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
matlab开发-serialize。从变量创建matlab代码
ajax-axios-url-form-serialize 插件
前端项目-jquery-serialize-object,serialize form fields into an object or JSON
对话框序列号例程serialize
:bowl_with_spoon: ts_serialize 零依赖库,用于序列化数据。 ts_serialize可以帮助您: 将camelCase类成员转换为snake_case JSON属性以与REST API一起使用从REST API有效负载中排除内部字段将数据类型转换为内部...
swoole_serialize是目前php7中最快的序列化函数
const { serializeError , deserializeError } = require ( 'serialize-error' ) ; const error = new Error ( ':unicorn:' ) ; console . log ( error ) ; //=> [Error: :unicorn:] const serialized = ...
form-serialize-and-calculate.html
用于GoPHP 和 。安装更新go get -u github.com/elliotchance/phpserialize phpserialize需要Go 1.8+。例子package mainimport ("fmt""github.com/elliotchance/phpserialize")func main () {out , err := ...
Monero Python序列化库 该库为Monero类型提供了基本的序列化逻辑,用于事务处理和事务签名中。 主要支持与Monero BEGIN_SERIALIZE_OBJECT()等效的二进制序列化。 该序列化机制用于区块链实体序列化。 增加了可移植...