新浪云计算数据缓存性能测试(文件、KVDB、Memcache)
2015-05-28 11:17
543 查看
<?php $times = 1000; //测试的次数 $str_len = 50000; //数据长度 $storage_domain = 'test1'; //存储域 function genRandomString($len) { $chars = array( "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ); $output = ""; for ($i=0; $i<$len; $i++) { $output .= $chars[mt_rand(0, 61)]; } return $output; } $content = genRandomString($str_len); //写入文本文件测试 $s = new SaeStorage(); $starttimer = microtime(true); for($o = 0 ; $o < $times; $o++){ $s->write($storage_domain, 'test'.$o.'.txt', $content); } $stoptimer = microtime(true); $timer = $stoptimer-$starttimer; echo "Data Write $times times by txt in $timer seconds.<br />"; //读取文本文件测试 $starttimer = microtime(true); for($o = 0 ; $o < $times; $o++){ $s->read($storage_domain, 'test'.$o.'.txt'); } $stoptimer = microtime(true); $timer = $stoptimer-$starttimer; echo "Data Read $times times by txt in $timer seconds.<br />"; unset($s); //KVDB写入测试 $kv = new SaeKVClient(); $kv->init(); $starttimer = microtime(true); for($o = 0 ; $o < $times; $o++){ $kv->set('test'.$o, $content); } $stoptimer = microtime(true); $timer = $stoptimer-$starttimer; echo "Data Write $times times by KVDB in $timer seconds.<br />"; //KVDB读取测试 $starttimer = microtime(true); for($o = 0 ; $o < $times; $o++){ $kv->get('test'.$o); } $stoptimer = microtime(true); $timer = $stoptimer-$starttimer; echo "Data Read $times times by KVDB in $timer seconds.<br />"; unset($kv); //Memcache写入测试 $mmc = memcache_init(); $starttimer = microtime(true); for($o = 0 ; $o < $times; $o++){ memcache_set($mmc, 'test'.$o, $content); } $stoptimer = microtime(true); $timer = $stoptimer-$starttimer; echo "Data Write $times times by Memcache in $timer seconds.<br />"; //Memcache读取测试 $starttimer = microtime(true); for($o = 0 ; $o < $times; $o++){ memcache_get($mmc, 'test'.$o); } $stoptimer = microtime(true); $timer = $stoptimer-$starttimer; echo "Data Read $times times by Memcache in $timer seconds.<br />"; unset($mmc); ?>
相关文章推荐
- mysql 序列化缓存到txt文件查找数据与直接查找数据 性能对比,13,601条数据文件缓存平均0.085秒后只需0.025秒 推荐 程序员导航网http://www.je666.com
- 《使用云计算和大数据进行性能测试》
- 【分享】我们用了不到200行代码实现的文件日志系统,极佳的IO性能和高并发支持,附压力测试数据
- PHP文件缓存的性能测试
- 03_MyBatis基本查询,mapper文件的定义,测试代码的编写,resultMap配置返回值,sql片段配置,select标签标签中的内容介绍,配置使用二级缓存,使用别名的数据类型,条件查询ma
- PHP文件缓存的性能测试(二)
- 03_MyBatis基本查询,mapper文件的定义,测试代码的编写,resultMap配置返回值,sql片段配置,select标签标签中的内容介绍,配置使用二级缓存,使用别名的数据类型,条件查询ma
- php中Apc和memcache缓存数据性能对比
- 讲解PHP文件缓存的性能测试
- 《使用云计算和大数据进行性能测试》
- PHP文件缓存的性能测试
- php中Apc和memcache缓存数据性能对比
- PHP 文件缓存的性能测试
- OpenWrt中对USB文件系统的操作, 以及读写性能测试
- MongoDB 1000W级数据 Insert和Query和Delete性能测试(分别测试 不加索引 和 加索引)
- 使用intel NASPT工具测试samba读写文件性能
- 缓存Integer等类型的频繁使用的数据和对象,大幅度提升性能
- YDB与spark SQL在百亿级数据上的性能对比测试
- 测试SQL Server 语句性能时需要先清空缓存