lang/php

텍스트 치환 함수 속도 String Replacement Method Speed

C/H 2018. 4. 26. 08:30

Result

sprintf > str_replace > preg_replace > strtr
strtr 과 str_replace 간 특성차이를 고려.

Run Speed

거론된 결과물이 많지만 1,2 만...

  1. str_replace #1 1.33 : 1 sprintf
  2. str_replace #2 1.6 : 1 sprintf
  3. preg_replace 2.19 : 1 sprintf
  4. strtr 51.97 : 1 sprintf
  1. sprintf: 2.92035603523 seconds
  2. preg_replace: 5.3017771244 seconds
  3. str_replace #1: 7.66827106476 seconds
  4. str_replace #2: 8.1126139164 seconds
  5. strtr: 145.762818813 seconds


반응형