| 56 | | public function bench() |
|---|
| 57 | | { |
|---|
| 58 | | Benchmark::start('using_array'); |
|---|
| 59 | | $output = array(); |
|---|
| 60 | | for ($i = 0; $i < 1000; $i++) |
|---|
| 61 | | { |
|---|
| 62 | | $output[] = ($i % 2 == 0) ? 'a' : 'b'; |
|---|
| 63 | | } |
|---|
| 64 | | $output = implode('', $output); |
|---|
| 65 | | $array = Benchmark::get('using_array'); |
|---|
| 66 | | |
|---|
| 67 | | unset($i, $output); |
|---|
| 68 | | |
|---|
| 69 | | Benchmark::start('using_string'); |
|---|
| 70 | | $output = ''; |
|---|
| 71 | | for ($i = 0; $i < 1000; $i++) |
|---|
| 72 | | { |
|---|
| 73 | | $output .= ($i % 2 == 0) ? 'a' : 'b'; |
|---|
| 74 | | } |
|---|
| 75 | | |
|---|
| 76 | | $string = Benchmark::get('using_string'); |
|---|
| 77 | | |
|---|
| 78 | | echo Kohana::debug('imploded array: ', $array, 'string append: ', $string); |
|---|
| 79 | | } |
|---|
| 80 | | |
|---|