Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#16684 closed enhancement (fixed)

PHP5 Performance improvement for wptexturize

Reported by: solarissmoke's profile solarissmoke Owned by:
Milestone: 3.2 Priority: normal
Severity: normal Version: 3.1
Component: Performance Keywords: php5 has-patch
Focuses: Cc:

Description

Now that we have ditched PHP4 we can do foreach() loops passing array elements by reference. Currently in wptexturize() we make a copy of each array element from $textarr and then write to a separate $output variable. In PHP5 this is unnecessary as we can work directly on the elements of $textarr.

I'm guessing this will need unit tests but it certainly should be more efficient.

Attachments (3)

16684.diff (1.7 KB) - added by solarissmoke 14 years ago.
16684.patch (3.4 KB) - added by hakre 14 years ago.
Improved version.
performance.php (1.1 KB) - added by ryan 14 years ago.
Quick microtime perfomance test

Download all attachments as: .zip

Change History (9)

@solarissmoke
14 years ago

#1 @solarissmoke
14 years ago

  • Component changed from General to Performance
  • Type changed from defect (bug) to enhancement

@hakre
14 years ago

Improved version.

#2 @hakre
14 years ago

  • Version set to 3.1

Thanks for reporting this.

Reviewed, tested and benchmarked 16684.diff. Better performance compared to the original, looks good.

However there is more to improve as I could find out in benchmarks, even on shorter strings this is double to triple the improvement of 16684.diff.

Last edited 14 years ago by hakre (previous) (diff)

#3 @ryan
14 years ago

16684.patch passes TestWPTexturize unit tests.

@ryan
14 years ago

Quick microtime perfomance test

#4 @ryan
14 years ago

5000 runs with performance.php yields numbers like 10.505 seconds without the patch and 9.510 with.

#5 @ryan
14 years ago

  • Milestone changed from Awaiting Review to 3.2

#6 @ryan
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [17636]) Performance improvements for wptexturize(). Props solarissmoke, hakre. fixes #16684

Note: See TracTickets for help on using tickets.