output buffering vs string concatenation / ob vs 拼接字符串
来源:互联网 发布:java设计模式有几种 编辑:程序博客网 时间:2024/06/17 18:08
点击打开链接http://stackoverflow.com/questions/6934762/php-performance-difference-between-string-concat-and-buffering-contents
<?php$test_1_start = microtime();$str = '';for ( $x = 0; $x <= 10000; $x++ ) { $str .= 'I am string ' . $x . "\n";}$test_1_end = microtime();unset($str);echo 'String concatenation: ' . ( $test_1_end - $test_1_start ) . ' seconds';$test_2_start = microtime();ob_start();for ( $x = 0; $x <= 10000; $x++ ) { echo 'I am string ', $x, "\n";}$str = ob_get_contents();ob_end_clean();$test_2_end = microtime();echo "\nOutput buffering: " . ( $test_2_end - $test_2_start ) . ' seconds';?>
$ php -vPHP 5.3.4 (cli) (built: Dec 15 2010 12:15:07) Copyright (c) 1997-2010 The PHP GroupZend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies$ php test.phpString concatenation: 0.003932 secondsOutput buffering: 0.002841 seconds%$ php test.phpString concatenation: 0.004179 secondsOutput buffering: 0.002796 seconds%$ php test.phpString concatenation: 0.006768 secondsOutput buffering: 0.002849 seconds%$ php test.phpString concatenation: 0.004925 secondsOutput buffering: 0.002764 seconds%$ php test.phpString concatenation: 0.004066 secondsOutput buffering: 0.002792 seconds%$ php test.phpString concatenation: 0.004049 secondsOutput buffering: 0.002837 seconds%
0 0
- output buffering vs string concatenation / ob vs 拼接字符串
- php ob(output buffering)系列函数详解
- ob缓冲简介(PHP output buffering)
- Java String vs StringBuilder vs StringBuffer Concatenation Performance Micro Benchmark
- StringBuilder vs String concatenation in toString() in Java
- python output buffering
- vs 打印信息到Output
- String VS StringBuffer VS StringBuilder
- C# string vs String
- String字符串拼接陷阱
- String拼接字符串
- string+vs String.format ,append vs AppendFormat
- <string>VS<string.h>VS<cstring>
- Cannot use output buffering in output buffering display handlers
- C++ string函数 VS C语言字符串函数
- String——反转单词顺序VS左旋字符串
- String(+) vs StringBuffer(append)
- String vs StringBuilder
- 用vue实现点击按钮,滑出面板(二)完结版
- 网吧升级机房问题集
- linux c之fdopen(int fd, const char *type)使用总结
- BPM报销流程开发示例
- CentOS 7 firewalld使用简介
- output buffering vs string concatenation / ob vs 拼接字符串
- Hibernate学习笔记 查询简介
- 一些有用的小程序资料
- 【Awesome Power Mode】
- 记录phantomjs学习(二)
- java future
- 检测用户有无操作
- Scala中最常用数据结构Map和Tuple
- git学习